def __set__ (self, instance, value):
        """Intercept assignments to the external attribute"""
        assert isinstance(value,type({}))
        if isinstance(value,dict_observer):
            newvalue = value 
            # if the value is already a dict_observer,
            # assume that the value is already monitored.
        else:
            newvalue = dict_observer(value, self.observer)
            internal_attributename = self.internal_attributename 
            try:
                oldvalue = getattr(instance, internal_attributename)
            except AttributeError:
                setattr(instance, self.internal_attributename, newvalue)
                self.observer.list_assignment_new(instance, internal_attributename)
            else:
                setattr(instance, self.internal_attributename, newvalue)
                self.observer.list_assignment_replace(instance, internal_attributename, oldvalue)
Intercept assignments to the external attribute
recipes/Python/306865_Observer_pattern_scalar/recipe-306865.py