On 04/26/2013 12:34 AM, Greg Ewing wrote:
Or if, as Guido says, the only sensible things to use
as enum values are ints and strings, just leave anything
alone that isn't one of those.

The standard Java documentation on enums:

   http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html

has an example enum of a "Planet", a small record type containing mass and radius--each of which are floats. I don't know whether or not it constitutes good programming, but I'd be crestfallen if Java enums were more expressive than Python enums ;-)

FWIW I'm +0.5 on "the enum metaclass ignores callables and descriptors". This seems reasonably Pythonic, much more so than "ignore everything except ints and strings". And as long as we're special-casing it I think we should opt for flexibility. Certainly I see nothing wrong with enums of float, complex, Decimal, and Fraction, so I don't see a good place to draw the line with a whitelist.


//arry/
_______________________________________________
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

Reply via email to