Okay does anyone know how to decorate class member functions? The following code gives me an error:
Traceback (most recent call last): File "decorators2.py", line 33, in <module> s.update() File "decorators2.py", line 13, in __call__ retval = self.fn.__call__(*args,**kws) TypeError: update() takes exactly 1 argument (0 given) ------------------ #! /usr/bin/env python class Bugger (object): def __init__ (self, module, fn): self.module = module self.fn = fn def __call__ (self,*args, **kws): ret_val = self.fn(*args,**kws) return ret_val def instrument (module_name): ret_val = lambda x: Bugger(module_name, x) return ret_val class Stupid: def __init__(self): self.val = 1 @instrument("xpd.spam") def update(self): self.val += 1 s = Stupid() s.update() -- http://mail.python.org/mailman/listinfo/python-list