George Sakkis wrote:
Yes, just return an actual function from the decorator instead of a callable object:def test_decorator2(func): def wrapper(*args): print 'Decorator2:', args func(*args) return wrapper class cls(object): @test_decorator def meth(self,*args): print 'Method: ', args @test_decorator2 def meth2(self,*args): print 'Method2: ', args
Thanks! This has the merit over Peter's solution that it seems to work for both functions and methods. However, as you can see from my answer to Peter, I think I will go for a class based approach anyway. Still, your answer helped me grasping the concepts.
/MiO -- http://mail.python.org/mailman/listinfo/python-list
