September 2026
1051 pages
35h 4m
English
One advantage of the enum enumeration type is that the symbolic enumeration values are strictly separated from their internal representations. For this reason, the comparison between the symbolic value Weekday.Monday and the numeric value 1 always evaluates to False, even though the value 1 is the internal representation of Weekday.Monday in the enumeration.
Occasionally, however, this kind of comparability is explicitly desired. For this purpose, the enum module contains the IntEnum data type, which can be used in a similar way to enum. Enumeration values of an enumeration type that inherits from IntEnum can be used as if they were integers:
>>> class Weekday(enum.IntEnum):... Monday = 1... Tuesday ...
Read now
Unlock full access