On 2/9/2017 2:03 AM, ast wrote:
Hi
In python courses I read, it is explained that
@decor
def f():
pass
is equivalent to:
def f():
pass
f = decor(f)
But that's not always true. See this code
Which is why the official docs now say 'roughly equivalent'
'''
For example, the following code
@f1(arg)
@f2
def func(): pass
is roughly equivalent to
def func(): pass
func = f1(arg)(f2(func))
except that the original function is not temporarily bound to the name func.
'''
Perhaps "There are also cases in which evaluating 'fi(arg)' before
rather than after the def statement makes a difference." should be added.
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list