[Python-Dev] PEP-435 reference implementation

Steven D'Aprano steve at pearwood.info
Wed May 1 09:05:36 CEST 2013

On Tue, Apr 30, 2013 at 09:19:49PM -0700, Ethan Furman wrote:
> Latest code available at https://bitbucket.org/stoneleaf/aenum.
> --> class Color(Enum):
> ...     red = 1
> ...     green = 2
> ...     blue = 3

Ethan, you seem to be writing a completely new PEP in opposition to 
Barry's PEP 435. But your implementation doesn't seem to match what your 
proto-PEP claims.

Your proto-PEP (file enum.txt) says:

``Enum` - a valueless, unordered type.  It's related integer value is merely to
    allow for database storage and selection from the enumerated class. An
    ``Enum`` will not compare equal with its integer value, but can compare equal
    to other enums of which it is a subclass.


py> import aenum
py> class Color(aenum.Enum):
...     red = 1
py> Color.red == 1
py> type(Color.red) is int

So the implemented behaviour is completely different from the documented 
behaviour. What gives?

Given the vast number of words written about enum values being instances 
of the enum class, I'm surprised that your proto-PEP doesn't seem to 
mention one word about that. All it says is that enum values are 
singletons. (Unless I've missed something.)


More information about the Python-Dev mailing list