If it doesn't execute on function call, I don't get what the use is? I thought if I did this, it would print out "I am decorator" ( but it only does it on function declaration )
def dec(f): print "I am decorator!", f return f @dec def fn(x): return x ( And if it doesn't, then the logThisMethodCall() will not be logging every time it is called, just once on declaration ?: ) On Wed, Dec 31, 2008 at 4:05 PM, Lenard Lindstrom <le...@telus.net> wrote: > An instance of function fn is created, then function decorator is called with > that instance as its only argument. > decorator then returns the function > instance, which is assigned to identifier fn. So a decorator is called when a > > function declaration is executed, not later when the function is called. >-- Jake