When I run this
from enum import Enum
class MyEnumType(str, Enum):
RED = 'RED'
BLUE = 'BLUE'
GREEN = 'GREEN'
for x in MyEnumType:
print(x)
I get the following as expected:
MyEnumType.RED
MyEnumType.BLUE
MyEnumType.GREEN
Is it possible to create a class like this from a list or tuple that has been obtained from elsewhere?
Something vaguely similar to this perhaps:
myEnumStrings = ('RED', 'GREEN', 'BLUE')
class MyEnumType(str, Enum):
def __init__(self):
for x in myEnumStrings :
self.setattr(self, x,x)
However, in the same way as in the original, I don't want to have to explicitly instantiate an object.