class Container(object):

    def __init__(self, data):
        self.data = data

def __setattr__(self, name, value):
    if not hasattr(self, name) or getattr(self, name) != value:
        self.on_change()
super(Container, self).__setattr__(name, value)

def on_change(self):
    pass


class SomeClass(object):

    def __init__(self, attr):
        self._attr = attr
self._attr.on_change = self._on_change

@property
def attr(self):
    return self._attr

@attr.setter
def attr(self, value):
    if self._attr != value:
        self._on_change()
self._attr = value

def _on_change(self):
    print('Do some code here every time attr changes')
Отслеживание изменений изменяемого атрибута в python