Detect when a class member is updated

Steve Holden sholden at holdenweb.com
Wed Jan 15 15:42:49 CET 2003


"Boethius" <boethius at techie.com> wrote in message
news:67446a0a.0301150634.f6d0c43 at posting.google.com...
> 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?

Take a look at "setattr()" generally, and the __setattr__() special method
inparticular. This allows you to trap access to attributes.

regards
--
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/
Bring your musical instrument to PyCon!    http://www.python.org/pycon/







More information about the Python-list mailing list