This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author barry
Recipients barry, cool-RR, eli.bendersky, ethan.furman
Date 2014-09-27.16:46:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
On Sep 27, 2014, at 04:15 PM, Ram Rachum wrote:

>The main principle is: If something has an important property (in this case
>an enum object's numerical value), it should be publicly exposed.

I think this is a misunderstanding.  Only IntEnum members have a defined
numerical value.  Base Enum members have no inherent value semantics except
their existence.  The *syntax* of using integers for values is simply a
convention and one that's not even necessary for Enums to work properly.

Enum members are also defined to be unordered, so their serial number is
meaningless.  The fact that __members__ is an ordered dictionary is a
convenient implementation detail that's only exposed in the API to support
iteration over all members including aliases.

Let me say specifically that I am opposed to int() for coercion for
non-IntEnums because Enum values can be anything.  Likewise, member.number is
also a misnomer in this case:

>>> from enum import Enum
>>> class Colors(Enum):
...    a = 'a'
...    b = 'b'
...    c = 'c'
>>> Colors.a is Colors.b
>>> Colors.a is Colors.a

I think using IntEnums or a subclass to provide a convenient wrapper around
__members__ iteration is the only thing that makes sense here, but I still
don't think the stdlib needs to support it.  IMHO, this is a case where adding
to the public stdlib API would provide more complexity for little common
Date User Action Args
2014-09-27 16:46:11barrysetrecipients: + barry, eli.bendersky, cool-RR, ethan.furman
2014-09-27 16:46:11barrylinkissue22505 messages
2014-09-27 16:46:11barrycreate