def __set__ (self, instance, value):
        """Intercept assignments to the external attribute"""
        assert isinstance(value, type([]))
        if isinstance(value, list_observer):
            newvalue = value 
            # if the value is already a list observer, assume that this value
            # already has an observer. Do new create a new list in this case.
        else:
            newvalue = list_observer(value, self.observer)
        internal_attributename = self.internal_attributename 
        try:
            oldvalue = getattr(instance, internal_attributename)
        except AttributeError:
            self.observer.list_assignment_new(instance, internal_attributename)
        else:
            self.observer.list_assignment_replace(instance, internal_attributename, oldvalue)
        setattr(instance, self.internal_attributename, newvalue)
Intercept assignments to the external attribute
recipes/Python/306865_Observer_pattern_scalar/recipe-306865.py