[Python-Dev] Enum Eccentricities

Ethan Furman ethan at stoneleaf.us
Mon Sep 23 01:52:36 CEST 2013


http://bugs.python.org/issue19011

So, as anyone who has worked with Enum is probably aware by now, Enum's are a strange duck -- you might even call them 
platypuses.

For example, Enum members are instances of the class, but they are defined inside the class structure, and new ones 
cannot be created afterwards; Enum classes also support iteration and containment checks.

What I'm looking for feedback on is the question is #19011: should an Enum member be considered a class level attribute?

On the one hand, they are defined inside the class, and they are accessed via dot notation (EnumClass.member).

On the other hand, inside the class they look like 3 and 5 and 'up' and 'east', and they don't live in the class dictionary.

Also, if we change Enum so that members do act more like class attributes, then things like Color.red.blue.green.blue 
will result in Color.blue, and that seems stranger to me than having class instances be available on the class without 
be full-fledged class-attributes.

Thoughts?  Opinions?  Pearls of wisdom?

--
~Ethan~


More information about the Python-Dev mailing list