On 04/29/2013 05:38 PM, Greg Ewing wrote:
Ethan Furman wrote:
I suppose the other option is to have `.value` be whatever was assigned (1,
'really big country', and (8273.199, 517) ),
I thought that was the intention all along, and that we'd
given up on the idea of auto-assigning integer values
(because it would require either new syntax or extremely
dark magic).
Not that dark, actually -- just a little dim. ;)
I just had it stuck in my head that every enum item would have an integer associated with it, and possibly have another
value as well.
So, for example:
--> class Constants(float, Enum):
... e = 2.81843 # am I close?
... pi = 3.141596
... tau = 2 * pi
I cannot do
--> Constants(2)
and get pi. I have to do
--> Constants(3.141596)
and given the nature of floating point I can see that failing at some, er,
point.
Likewise, if I have normal, but jumbled, Enum:
--> class Jumble(Enum):
... eggs = 1
... method = 'scramble'
... cost = 2.5
then to get method back I have to use
--> Jumble('scramble')
It just seems odd to me. Oh, and it would seem just as odd using __getitem__.
;)
--
~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