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: Hypnotic Puzzle3

--

Chapters
00:00 Get Enumeration Name By Value
00:18 Accepted Answer Score 391
00:27 Answer 2 Score 47
00:35 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'