Это Что у меня есть: < /p>
Код: Выделить всё
>>> class Blub(object):
... def __init__(self, value):
... print('Blub is ' + value)
... self.value = value
... def __get__(self):
... print('Blub gets ' + self.value)
... return self.value
... def __set__(self, value):
... print('Blub becomes ' + value)
... self.value = value
...
>>> class Quish(object):
... def __init__(self, value):
... self.blub = Blub(value)
... def __get__(self):
... return self.blub
... def __set__(self, value):
... self.blub = Blub(value)
...
< /code>
Это то, что я хочу, и не знаю, как сделать: < /p>
>>> a = Quish('One')
Blub is One
>>> a.blub
Blub gets One
'One'
a.blub = 'Two'
Blub becomes Two
Код: Выделить всё
>>> a.blub.__get__()
Подробнее здесь: https://stackoverflow.com/questions/198 ... et-and-set
Мобильная версия