[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library (original) (raw)
Barry Warsaw barry at python.org
Fri Apr 26 00:07:19 CEST 2013
- Previous message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Next message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Apr 25, 2013, at 02:30 PM, Ethan Furman wrote:
--> class Animal(Enum): ... ant = 1 ... bee = 2 ... fly = 3
--> Animal(2) # should return Animal.bee --> Animal('ant') # should return Animal.ant It seems to me that storing the instances on the class as attributes is mostly for convenience; we could just as easily not, and change the repr of enumerators to ' ant [int=1]'.
So I guess you would still expect these to hold true:
>>> Animal.ant is Animal(2)
True
>>> Animal.ant is Animal('ant')
True
-Barry
- Previous message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Next message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]