Skip to content
Advertisement

How to retrieve an Enum key via variable

I’m new to python. Is it possible to get the value of an Enum key from a variable key?

JavaScript

Advertisement

Answer

One of the many neat features of Python’s Enums is retrieval by name:

JavaScript

and for the value:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement