I have a class that acts like an enum. I want to loop over his variables (enum's values)
class Demos(object):
class DemoType(object):
def __init__(self, name):
self.name = name
def __repr__(self):
return self.name
VARIABLE1 = DemoType("Car")
VARIABLE2 = DemoType("Bus")
VARIABLE3 = DemoType("Example")
VARIABLE4 = DemoType("Example2")
I thought about using Role.__dict__
, or vars(Role)
, but they contain not only the variables, but also the RoleType
class and other attributes like __module__
. __doc__
and more...
I also want it to be represented like this, mainly because it will add more variables to DemoType
. variables other than name
, So please try to find an answer this way.