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.
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:
Python 3.11 or higher
pip
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 KarpierzLicensed under the zlib/libpng LicensePlease refer to the accompanying LICENSE file.
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.
Metadata
Release files for renumerate 2.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| renumerate-2.5.1.tar.gz | 13.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| renumerate-2.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.1 kB
Release files / renumerate-2.5.1.tar.gz
| Download URL | renumerate-2.5.1.tar.gz |
|---|---|
| Size | 13.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a82aaa9cddb090254fe32325d06ed97b790546b0f53257a32542487580ddb14c
|
|
BLAKE2b-256 checksum How to use checksums |
eecf3e374c75b93f014f8feef23fe7729ec84543eeb83e34868ee54940d8e016
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / renumerate-2.5.1-py3-none-any.whl
| Download URL | renumerate-2.5.1-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5afa5e8d29af9d7ee1ad6ce119d5ddc9c3beff8fdc89be592c8d8369dd52641b
|
|
BLAKE2b-256 checksum How to use checksums |
03796dcc121c241c5f914cf482cf31667790deba4e4818b4d7c7e843e05425a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|