Skip to main content

Reverse enumerate.

Reason this release was yanked:

Setup failed (due to backward compatibility problem with newest deepdiff).

Project description

renumerate

Reverse enumerate.

Overview

renumerate(sequence, start=len(sequence)-1, end=0)

Return an enumerate object.
sequence must be an object that has a __reversed__() method or supports the sequence protocol (the __len__() method and the __getitem__() method with integer arguments starting at 0).
The __next__() method of the iterator returned by renumerate() returns a tuple containing a count (from start which defaults to len(sequence) - 1 or ends at end which defaults to 0 - but not both) and the values obtained from reverse iterating over sequence.

PyPI record.

Documentation.

Usage

>>> from renumerate import renumerate
>>> seasons = ['Spring', 'Summer', 'Fall', 'Winter']
>>> list(renumerate(seasons))
[(3, 'Winter'), (2, 'Fall'), (1, 'Summer'), (0, 'Spring')]
>>> list(renumerate(seasons, start=4))
[(4, 'Winter'), (3, 'Fall'), (2, 'Summer'), (1, 'Spring')]
>>> list(renumerate(seasons, end=2))
[(5, 'Winter'), (4, 'Fall'), (3, 'Summer'), (2, 'Spring')]

Equivalent to:

def renumerate(sequence, start=None, end=None):
    if start is not None and end is not None:
        raise TypeError("renumerate() only accepts start argument or end argument"
                        " - not both.")
    if start is None: start = len(sequence) - 1
    if end   is None: end   = 0
    n = start + end
    for elem in reversed(sequence):
        yield n, elem
        n -= 1

Installation

Prerequisites:

To install run:

python -m pip install --upgrade renumerate

Development

Prerequisites:

  • Development is strictly based on nox. To install it run:

    python -m pip install --upgrade nox

Visit Development page.

Installation from sources:

clone the sources:

git clone https://github.com/karpierz/renumerate renumerate

and run:

python -m pip install ./renumerate

or on development mode:

python -m pip install --editable ./renumerate

License

Copyright (c) 2016-2026 Adam Karpierz
Licensed under the zlib/libpng License
Please refer to the accompanying LICENSE file.

Authors

Sponsoring

If you would like to sponsor the development of this project, your contribution is greatly appreciated.
As I am now retired, any support helps me dedicate more time to maintaining and improving this work.

Donate

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

renumerate-2.4.2.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

renumerate-2.4.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file renumerate-2.4.2.tar.gz.

File metadata

  • Download URL: renumerate-2.4.2.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for renumerate-2.4.2.tar.gz
Algorithm Hash digest
SHA256 c4afc4ee36bad667ca49c2f6157602f46d0ba8a9401a6601ea1b46f1b16f202e
MD5 994546ad9f0c90362471a3088dc42d8f
BLAKE2b-256 9e38d6edc7ea4a22b2437c3d92612551f863fd5312aba52523f66d6c062d4a99

See more details on using hashes here.

File details

Details for the file renumerate-2.4.2-py3-none-any.whl.

File metadata

  • Download URL: renumerate-2.4.2-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for renumerate-2.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5900dc276e74866ed70eb1abab02f386484d32600118e211e6104f09b5dbd50c
MD5 ee098fb294206541136e4e684ccd05d6
BLAKE2b-256 0815256a53b2f42c2537b748ed8f39e1b98baa019ca4ed4de2f3577b8d3a462c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page