Ron Garret wrote: > The reason I want to do this is that I want to implement a trace > facility that traces only specific class methods. I want to say: > > trace(c1.m1) > > and have c1.m1 be replaced with a wrapper that prints debugging info > before actually calling the old value of m1. The reason I want that to > be an instance of a callable class instead of a function is that I need > a place to store the old value of the method so I can restore it, and I > don't want to start building a global data structure because that gets > horribly ugly, and a callable class is the Right Thing -- if there's a > way to actually make it work.
If the only reason for a callable class is to save a single value (the original function), you could instead store it as an attribute of the wrapper function. Kent -- http://mail.python.org/mailman/listinfo/python-list