Is it possible to do something like this in Python?
class MyClass():
def __init__(self):
someValue = 42
str = 'a'
# self.a = someValue
str = 'xyz'
# self.xyz = someValue
Essentially what I want to achieve is by reading the value of str (say the value of str resolves to 'myValue'), the code adds an additional attribute (self.myValue) into the class.
Aucun commentaire:
Enregistrer un commentaire