I am trying to understand the functioning of decorators. What am i doing wrong in the following code. Please do correct it
As I have understood when aFunction() is called it in turn calls myDecorator() which also makes a call to afunction(). Right?
Also how to pass parameters into afunction()
class myDecorator(object):
def __init__(self, f):
print "inside myDecorator.__init__()"
f(1) # Prove that function definition has completed
def __call__(self):
print "inside myDecorator.__call__()"
@myDecorator
def aFunction(*a):
print a
print "inside aFunction()"
print "Finished decorating aFunction()"
aFunction(2)