2016-09-28 6 views

답변

0

시도 뭔가 :

class A(object): 
    def __init__(self): 
     self._my_attr = None 
     self.property_changed = Subject() 
    ... 
    @property 
    def my_attr(self): 
     return self._my_attr 

    @my_attr.setter 
    def my_attr(self, value): 
     if value != self._my_attr: 
      self._my_attr = value 
      self.property_changed.on_next(('my_attr', value)) 

a = A() 
a.property_changed.subscribe(print) 
a.my_attr = 1 
a.my_attr = 3