I want to convert string to class member name.
my question looks like this:
class Constant():
def add_Constant(self, name, value):
self.locals()[name] = value # <- this doesn't work!
# def
# class
to do this:
CONST = Constant()
CONST.add_Constant(name='EULER', value=2.718)
print(CONST.EULER)
But above code doesn't work. Is there any way to add class members based on strings?