Ethan Furman wrote:
Experimenting is good! However, you'll want to either build your own metaclass and/or prepared dict, or do some work on your __new__/__init__ methods for building enum members. Currently, you are reassigning _value_ in __init__, which leaves some internal structures not matching the Enum. --> class Food(ChoiceEnum): ... APPLE = () ... ICED_TEA = () ... --> Food['APPLE'] <Food.APPLE: 'APPLE'> --> Food.APPLE <Food.APPLE: 'APPLE'> --> Food('APPLE') Traceback (most recent call last): ... ValueError: 'APPLE' is not a valid Food
Thanks for that info. Per the example in https://docs.python.org/3/library/enum.html#when-to-use-new-vs-init, it looks like I can properly set the `_value_` property in the `__new__` method of the `Enum` subclass without needing to subclass `EnumMeta`. Am I understanding that correctly?