By definition, the enumeration member values are unique. However, you can create different member names with the same values.
Two enum names can have same value. For example, in the following C program both 'Failed' and 'Freezed' have same value 0.
Use a list comprehension to get a list of all enum values, e.g. values = [member. value for member in Sizes] . On each iteration, access the value attribute on the enum member to get a list of all of the enum's values.
There is currently no way to detect or prevent multiple identical enum values in an enum.
>>> Example(1).name
'one'
also see the Python docs.
To access the members of enums programatically:
>>> Example(ex_variable).name
'one'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With