[issue43430] Exception raised when attempting to create Enum via functional API

Ethan Furman report at bugs.python.org
Wed Apr 21 08:15:57 EDT 2021


Ethan Furman <ethan at stoneleaf.us> added the comment:

That sounds more like the way it is intended to be used: make you base enum with all the changes you want, then use that base enum either by inheriting from it or as a function call:

    class MyBaseEnum(Enum, metaclass=...):
        ... custom stuff ...
        ... custom stuff ...

    class MyRealEnum1(MyBaseEnum):
        NAME = value
        NAME = value

    MyRealEnum2 = MyBaseEnum("MyRealEnum2", [('NAME', value), ('NAME', value)])

What change did you need with `__getitem__`?  Maybe there is a way to accomplish that goal without subclassing EnumMeta.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43430>
_______________________________________


More information about the Python-bugs-list mailing list