Catching all methods before they execute

jamesthiele.usenet at gmail.com jamesthiele.usenet at gmail.com
Mon Mar 7 13:15:27 EST 2005


I have run into some cases where I would like to run a class method
anytime any class method is invoked.
That is, if I write
x.foo

then it will be the same as writing
x.bar
x.foo

for any method in class x (with the possible exception of 'bar').

The first few times I wanted to print out a data structure for
debugging purposes. Most recently it was to save a data structure to
allow "undo" operations. I've realized that this is a generalized
problem and I was hoping that someone could point me to the correct
hook to accomplish this (python seems to have a hook for everything).




More information about the Python-list mailing list