Detect when a class member is updated
jorgencederberg at hotmail.com
Wed Jan 15 15:53:45 CET 2003
> Can I detect when a class member is added or updated?
> I have a class with a member called path. Everytime it's updated, I'd
> like to run a 'sanity check' on the new value.
> How can I do this?
How about using properties, as this example shows. You could replace the
notify method with a validate method instead.
__value = 0
def set_value(self, value):
self.__value = value
print "Value was changed to", str(self.value)
value = property(get_value, set_value)
More information about the Python-list