The Python Oracle

Get enumeration name by value

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Luau

--

Chapters
00:00 Get Enumeration Name By Value
00:24 Accepted Answer Score 380
00:38 Answer 2 Score 46
00:49 Thank you

--

Full question
https://stackoverflow.com/questions/3871...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #enums #enumeration

#avk47



ACCEPTED ANSWER

Score 391


>>> Example(1).name
'one'

also see the Python docs.




ANSWER 2

Score 47


To access the members of enums programatically:

>>> Example(ex_variable).name
'one'