I have an enum.StrEnum
, for which I want to add attributes to the elements.
For example:
class Fruit(enum.StrEnum):
APPLE = ("Apple", { "color": "red" })
BANANA = ("Banana", { "color": "yellow" })
>>> str(Fruit.APPLE)
"Apple"
>>> Fruit.APPLE.color
"red"
How can I accomplish this? (I'm running Python 3.11.0.)
This question is not a duplicate of this one, which asks about the original enum.Enum
.