Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get enumeration name by value [duplicate]

People also ask

Can enum have two same values python?

By definition, the enumeration member values are unique. However, you can create different member names with the same values.

Can enum have duplicate values?

Two enum names can have same value. For example, in the following C program both 'Failed' and 'Freezed' have same value 0.

How do I get a list of enum names?

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.

Can enum have duplicate values C++?

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'