[issue26988] Add AutoNumberedEnum to stdlib
Ethan Furman
report at bugs.python.org
Sun Jul 10 13:42:18 EDT 2016
Ethan Furman added the comment:
I like AutoEnum.
Another auto-related thought: one of the more common Enum questions on StackOverflow is how to automatically have the value be the stringified version of the name:
class Huh(Enum):
this
that
those
Huh.this.name == Huh.this.value
# True
So the question then becomes: is there a way to easily support both auto-number and auto-string values?
While I don't have the auto-string feature yet in aenum, the system I am using to specify optional settings looks like this:
------
class Color(Enum, settings=AutoNumber):
red
...
------
------
class Color(IntEnum, settings=AutoNumber):
red
...
------
------
class Color(Enum, settings=AutoName):
red
...
------
The other option, of course, is to just stick with the prebuilt method of doing things:
class Color(AutoEnum):
...
class Color(AutoEnum, IntEnum):
...
class Color(AutoNameEnum):
...
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26988>
_______________________________________
More information about the Python-bugs-list
mailing list