[Python-Dev] AutoNumber Enum
ethan at stoneleaf.us
Wed Jun 29 15:13:40 EDT 2016
On 06/29/2016 11:15 AM, Brett Cannon wrote:
> On Wed, 29 Jun 2016 at 10:41 Ethan Furman wrote:
>> There is a several-month-old request to add aenum's  AutoNumberEnum
>> to the stdlib .
>> The requester and two of the three developers of Enum are in favor (the
>> third hasn't chimed in yet).
>> This new addition would enable the following:
>> from Enum import AutoNumberEnum
>> class Color(AutoNumberEnum):
>> # auto-number magic is on
>> # magic turns off when non-enum is defined
> Is it going to subclass Enum or IntEnum?
> Personally I would be quite
> happy to never have to specify a value for enums ever again, but only if
> they subclass Enum (since IntEnum is for compatibility with C stuff
> where a specific value is needed I don't think users need to mess that
> up by having the automatic numbering not work how they would expect).
If a user really wants that they can, of course, specify both
AutoNuberEnum and IntEnum in the class header.
More information about the Python-Dev