Reverse enumerate.
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 thesequence protocol (the __len__() method and the __getitem__() method withinteger arguments starting at 0).The __next__() method of the iterator returned by renumerate() returns a tuplecontaining a count (from start which defaults to len(sequence) - 1 or ends atend which defaults to 0 - but not both) and the values obtained from reverseiterating over sequence.
>>> 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.5 or higher
3.7 is a primary test environment.
pip and setuptools
To install run:
python -m pip install --upgrade renumerate
Development
Prerequisites:
Development is strictly based on tox. To install it run:
python -m pip install --upgrade tox
Visit development page.
Installation from sources:
clone the sources:
git clone https://github.com/karpierz/renumerate.git renumerate
and run:
python -m pip install ./renumerate
or on development mode:
python -m pip install --editable ./renumerate
License
Copyright (c) 2016-2020 Adam KarpierzLicensed under the zlib/libpng LicensePlease refer to the accompanying LICENSE file.
Changelog
1.0.11 (2020-09-17)
Add support for Python 3.9.
Setup general update and cleanup.
1.0.10 (2019-11-12)
Drop support for Python 3.4.
Add support for Python 3.8.
Setup update and cleanup.
1.0.9 (2019-05-22)
Drop support for Python 2.
1.0.8 (2019-05-21)
Update required setuptools version.
Setup update and improvements.
This is the latest release that supports Python 2.
1.0.7 (2018-11-08)
Drop support for Python 2.6 and 3.0-3.3.
Update required setuptools version.
1.0.6 (2018-05-08)
Fix a bug in description.
Update required setuptools version.
Improve and simplify setup and packaging.
1.0.5 (2018-02-26)
Improve and simplify setup and packaging.
1.0.4 (2018-01-28)
Fix a bug and inconsistencies in tox.ini
Update of README.rst.
1.0.1 (2018-01-24)
Update required Sphinx version.
Update doc Sphinx configuration files.
1.0.0 (2017-11-18)
Setup improvements.
Other minor improvements.
1.0.0b1 (2017-11-18)
Minor improvements.
0.3.4 (2017-01-05)
Minor setup improvements.
0.3.3 (2016-09-25)
Fix bug in setup.py
0.3.1 (2016-09-25)
More PEP8 compliant.
0.2.2 (2016-09-24)
Description suplement
Minor fixes.
0.1.1 (2016-09-24)
First useful release.
0.0.2 (2016-09-23)
Initial release.
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
File details
Details for the file renumerate-1.0.11.zip
.
File metadata
- Download URL: renumerate-1.0.11.zip
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f373a1ffc329c8d66e1ee3bb72fd6d4684518f8e2945a1e877db801519c1851a |
|
MD5 | ede7c72bcdfc15828317280f456e2640 |
|
BLAKE2b-256 | c03fc8a2241be4d642c2435457e73fc9eef89e950b181a4c0a5730b20db26145 |