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.0.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.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: renumerate-2.4.0.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.0.tar.gz
Algorithm Hash digest
SHA256 8a9dc62c004d923d866b45f0f0ee5314dc710f610402d88ab678c279aa684c8d
MD5 07f67c36a5482a6c62f2d73afeb812c4
BLAKE2b-256 41a5e7a5fd427bc9ec48f76799e9a973f1a048191dd10db34fe894f59eab5677

See more details on using hashes here.

File details

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

File metadata

  • Download URL: renumerate-2.4.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d561497218add7d11dc435b39d9ed14c452019ce9f94190c2ebe1a626cb77017
MD5 6ed19d4b40a1fce422c932ac3df82bef
BLAKE2b-256 0604050f0b6bd92db2f35328099e38c420b1cfba4d658ffee3dbd149b9accb66

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