Creating More Enumerations
More enumeration creation. You’ve already seen enumerations with
ints and strings, but you can also create enumerations of Boolean values. In this case, the members of your enumeration will have only two values.
00:58 However, this practice makes your code inconsistent from a type safety perspective, so it’s not recommended. Ideally, it would help if you had values of the same data type, which is consistent with the idea of grouping similar related constants in enumerations. You can also create empty enumerations.
In this example,
Empty represents an empty enumeration because it doesn’t define any member constants. Note that you can use the
pass statement, the ellipsis literal, or a class-level docstring to create empty enumerations.
Become a Member to join the conversation.