class StrLink(str):
def __new__(cls, content, parent, name, **kwargs):
return str.__new__(cls, content, **kwargs)
def __init__(self, content, parent, name, **kwargs):
str.__init__(content)
self.parent = parent
self.name = name
def update(self, new):
setattr(self.parent, self.name, new)
class TMP:
def __init__(self):
self.first_name = StrLink('Попов', parent=self, name='first_name')
print()
def set_info_to_atr(cls_atr, info):
cls_atr.update(info)
t = TMP()
print(t.first_name)
set_info_to_atr(t.first_name, 'Иван')
print(t.first_name)