This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add a new feature to enumerate(iterable, start=0) built-in function
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.11
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: HosseinRanjbari, pablogsal, rhettinger
Priority: normal Keywords:

Created on 2022-02-17 18:37 by HosseinRanjbari, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg413428 - (view) Author: Hossein (HosseinRanjbari) Date: 2022-02-17 18:37
Hi everyone. I have an idea which is add a new feature to enumerate(iterable, start=0) built-in function. I mean, "start" is ascending by default, we can add a feature to this function to change start in descending order.
for example:
enumerate(iterable, start=100, reverse=True)
reverse: If True, the start is reversed.
(100, iterable[0]), (99, iterable[1],), and so on.
msg413429 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2022-02-17 18:39
This has nothing to do with the parser so I'm removing the label. Please, next time make sure you select the appropriate categories when opening an issue
msg413448 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2022-02-17 19:49
Thank you for the suggestion, but we will decline.  We looked at this before and decided not to go down this path, preferring instead to the keep the builtin function simple and focused on its core task of enumeration.

To cover the rarer cases, it is a simple matter to fulfill the need with fast, clear code using itertools:

>>> from itertools import count
>>> names = ['eddard', 'catelyn', 'robb', 'sansa', 'arya', 'bram', 'rickon']
>>> for i, name in zip(count(start=7, step=-1), names):
        print(i, name)

7 eddard
6 catelyn
5 robb
4 sansa
3 arya
2 bram
1 rickon
History
Date User Action Args
2022-04-11 14:59:56adminsetgithub: 90939
2022-02-17 19:49:31rhettingersetstatus: open -> closed

assignee: rhettinger

nosy: + rhettinger
messages: + msg413448
resolution: rejected
stage: resolved
2022-02-17 18:43:09zach.waresetassignee: docs@python -> (no value)

nosy: - docs@python, lys.nikolaou
components: + Library (Lib), - Build, Demos and Tools, Documentation, Interpreter Core
versions: - Python 3.7, Python 3.8, Python 3.9, Python 3.10
2022-02-17 18:39:19pablogsalsetnosy: docs@python, lys.nikolaou, pablogsal, HosseinRanjbari
messages: + msg413429
components: - Parser
2022-02-17 18:38:31larrysetnosy: - larry
components: - Argument Clinic
2022-02-17 18:37:45HosseinRanjbaricreate