this is a same representation of my code and I just want to know if there is a way to obtain the result of the second action (word1) from the first action (word). The main objective here is that if I change the variable letter
, the assigned value should also be in respective to the variable inside the class.
class Test():
def __init__(self, x='world'):
self.a = 'hi {}'.format(x)
self.b = 'hello'
self.c = 'hey'
letter = 'a'
word = "Test(x='{}').{}".format('new world', letter)
print(word)
# prints Test(x='new world').a, expected 'hi new world'
word1 = Test(x='new world').a
print(word1)
# prints 'hi new world'