On 04/25/2013 03:07 PM, Barry Warsaw wrote:
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 '<Animal> 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
Well, except for ant being 1, yeah. ;)
--
~Ethan~
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com