[issue33437] Defining __init__ in enums

2019-01-09 Thread Cheryl Sabella
Change by Cheryl Sabella : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue33437] Defining __init__ in enums

2018-09-12 Thread miss-islington
miss-islington added the comment: New changeset f52237400b9960d434c5d0676a3479b8c1e8c869 by Miss Islington (bot) (Ethan Furman) in branch 'master': bpo-33437: add __new__ vs __init__ example (GH-9145) https://github.com/python/cpython/commit/f52237400b9960d434c5d0676a3479b8c1e8c869

[issue33437] Defining __init__ in enums

2018-09-10 Thread Ethan Furman
Change by Ethan Furman : -- pull_requests: +8593 stage: -> patch review ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue33437] Defining __init__ in enums

2018-05-08 Thread Ethan Furman
Ethan Furman added the comment: That new example looks great! Note that you don't need the parenthesis, though. FYI: The same thing using the aenum library* would look like: from aenum import Enum class Coord(bytes, Enum): _init_ = 'value label unit' PX

[issue33437] Defining __init__ in enums

2018-05-08 Thread Andres Ayala
Andres Ayala added the comment: I see, with mixed types you need to use __new__ to construct the elements (I imagine is specially important for non mutable types) I have modified the example of the coordinates to try to use a mixed type. Is not the most useful thing, but

[issue33437] Defining __init__ in enums

2018-05-07 Thread Ethan Furman
Ethan Furman added the comment: Setting _value_ needs to happen in __new__ for those cases where another data type, such as str or int, is mixed in. I'll look at adding an example to the docs. Thanks for the report! -- assignee: -> ethan.furman components:

[issue33437] Defining __init__ in enums

2018-05-07 Thread Andres Ayala
New submission from Andres Ayala : I have to read and write many files for an old fortran program where the elements are coded as integer (so 0 is the X, 1 is the Y...) and I have some tags associated to each one. So I tried to create an Enum with some additional fields: