def Test2():
    """
    A more realistic example for the OO programmer.
    """
    class Sprite(object):
        def __init__(self, location):
            self._location = location
        locationChanged = Dispatcher()
        def getLocation(self):
            return self._location
        def setLocation(self, newLocation):
            oldLocation = self._location
            self._location = newLocation
            # Dispatch a "property change event"
            self.locationChanged(oldLocation, newLocation)
        location = property(getLocation, setLocation)
    s = Sprite((2,4))
    def SpriteLocationChanged(oldLocation, newLocation):
        print 'oldLocation =', oldLocation
        print 'newLocation =', newLocation
    s.locationChanged += SpriteLocationChanged
    s.location = (3,4)
    s.location = (4,4)

    A more realistic example for the OO programmer.
    
recipes/Python/435885_General_dispatching_mechanism_Cstyle/recipe-435885.py