8 ms·
Yes I had to think about it and test it (not done much Python recently). The decorating function is called as soon as the decorated function is declared. These
by josephlord 12y ago
Yes I had to think about it and test it (not done much Python recently). The decorating function is called as soon as the decorated function is declared.
These are the results of a simple test in the Python console.
>>> def dec(f):
... print "Decorator ran"
... return f
...
>>> @dec
... def decorated(i):
... print "Decorated function ran"
...
Decorator ran
>>> decorated(5)
Decorated function ran
>>> decorated(5)
Decorated function ran