This has always seemed unfortunately long and boilerplatey:
class PickOne(Enum):
OPTION_A = "a"
OPTION_B = "b"
choice = PickOne.OPTION_A # todo: show what would print at this point
print(PickOne.OPTION_A.value) # "a"
TIL that Python 3.11 introduced StrEnum and IntEnum, which let you access the underlying value without that extra .value
:
print(PickOne.OPTION_A) # "a"
Itβs the little things.