[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

Larry Hastings larry at hastings.org
Fri Apr 26 17:50:16 CEST 2013

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:


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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130426/561c61c1/attachment.html>

More information about the Python-Dev mailing list