I have an enum Nationality:
class Nationality:
Poland='PL'
Germany='DE'
France='FR'
How can I convert this some enum to int in this or similar way:
position_of_enum = int(Nationality.Poland) # here I want to get 0
I know that I can do it if I had code by:
counter=0
for member in dir(Nationality):
if getattr(Nationality, member) == code:
lookFor = member
counter += 1
return counter
but I don't have, and this way looks too big for python. I'm sure that there is something much simpler .