Re: Understanding decorator and class methods

2014-01-08 Thread Terry Reedy
On 1/8/2014 2:56 PM, axis.of.wea...@gmail.com wrote: can someone please explain why the following works, in contrast to the second example? Because function attributes of classes become instance methods, with special behavior, when accessed via an instance of the class. def decorator(func)

Re: Understanding decorator and class methods

2014-01-08 Thread Rotwang
On 08/01/2014 19:56, axis.of.wea...@gmail.com wrote: can someone please explain why the following works, in contrast to the second example? def decorator(func): def on_call(*args): print args return func(args) return on_call class Foo: @decorator def bar(s

Understanding decorator and class methods

2014-01-08 Thread axis . of . weasel
can someone please explain why the following works, in contrast to the second example? def decorator(func): def on_call(*args): print args return func(args) return on_call class Foo: @decorator def bar(self, param1): print 'inside bar' f=Foo() f.bar(4)