I have an enum.Enum
subclass:
class MyEnum(Enum):
A = "apple"
C = "cherry"
B = "banana"
and I want to be able to use <
and >
to see if a given member comes before or after another one in the definition order, so I could do something like this:
>>> MyEnum.A < MyEnum.B
True
>>> MyEnum.B >= MyEnum.C
True
>>> MyEnum.C < MyEnum.A
False
based on where the values appear in the definitions of the enum, not the enum values themselves. I know that Enums preserve order, but there is no way of finding which came first. How can I accomplish this in Python 3.7?