
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2014-06-10 14:33 bydkorchem, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Messages (8) | |||
|---|---|---|---|
| msg220169 -(view) | Author: Dmitry Korchemny (dkorchem) | Date: 2014-06-10 14:33 | |
In enum module the functional API for enum creation has the following signature:Enum(value='NewEnumName', names=<...>, *, module='...', qualname='...', type=<mixed-in class>)so that the numeration always starts with 1. In some cases it is convenient to start numbering from other base, e.g., 0. It would be of great help to add an additional parameter, say start, to make the following call possible:Animal = Enum('Animal', 'ant bee cat dog', start = 0) | |||
| msg220209 -(view) | Author: Ethan Furman (ethan.furman)*![]() | Date: 2014-06-10 23:15 | |
That is certainly nicer than the current idiom: Animal = Enum('Animal', zip('ant bee cat dog'.split(), range(4))) | |||
| msg220210 -(view) | Author: Eli Bendersky (eli.bendersky)*![]() | Date: 2014-06-10 23:20 | |
Is it really worthwhile to complicate the API for the sake of providing a less flexible solution for rare cases that saves a few keystrokes? | |||
| msg220212 -(view) | Author: Ethan Furman (ethan.furman)*![]() | Date: 2014-06-10 23:34 | |
Playing devil's advocate:The issue is not so much the keystrokes saved as the improvement in reading and understanding what was intended. If you are happy with starting at 1 the idiom is easy to both write, read, and understand; but if you want some other starting number you have to uglify your code with parenthesis, .methods, and add an extra iterator which you have to manually re-sync if you later add another name...I think that is the real issue -- not keystrokes. | |||
| msg220237 -(view) | Author: Dmitry Korchemny (dkorchem) | Date: 2014-06-11 06:22 | |
I think that the situation when you want start numbering from 0 is rather common, especially when you need to define bit fields as enumeration or when you need to implement an interface with other languages (e.g., C). | |||
| msg220473 -(view) | Author: Terry J. Reedy (terry.reedy)*![]() | Date: 2014-06-13 17:55 | |
Looks sensible to me. Except for being name-only, this duplicates the api of enumerate. | |||
| msg226975 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2014-09-17 03:36 | |
New changesetec016ba862ba by Ethan Furman in branch 'default':Closeissue21706: add 'start' parameter to functional APIhttps://hg.python.org/cpython/rev/ec016ba862ba | |||
| msg227024 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2014-09-18 02:22 | |
New changeset713ee49ec3ba by Berker Peksag in branch 'default':Issue#21706: Add a versionchanged directive to the functional API docs.https://hg.python.org/cpython/rev/713ee49ec3ba | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:04 | admin | set | github: 65905 |
| 2014-09-18 02:22:33 | python-dev | set | messages: +msg227024 |
| 2014-09-17 03:36:23 | python-dev | set | status: open -> closed nosy: +python-dev messages: +msg226975 resolution: fixed stage: resolved |
| 2014-06-13 17:55:58 | terry.reedy | set | nosy: +terry.reedy messages: +msg220473 |
| 2014-06-11 06:22:40 | dkorchem | set | messages: +msg220237 |
| 2014-06-10 23:34:22 | ethan.furman | set | messages: +msg220212 |
| 2014-06-10 23:20:26 | eli.bendersky | set | messages: +msg220210 |
| 2014-06-10 23:15:57 | ethan.furman | set | assignee:ethan.furman messages: +msg220209 |
| 2014-06-10 14:56:58 | zach.ware | set | nosy: +barry,eli.bendersky,ethan.furman |
| 2014-06-10 14:33:48 | dkorchem | create | |