[Python-ideas] Tweaking closures and lexical scoping to include the function being defined

Stephen J. Turnbull stephen at xemacs.org
Sun Oct 2 09:26:13 CEST 2011


Ron Adam writes:

 > Pep 318 says it should translate to ...
[...]
 > add(3)  ---> 5      # call wrapper with x, which calls add with (x, y)
[...]
 > But the behavior is as you suggest...
[...]
 > add(3) ---> 5

That's what I get, too: the same result using decorator syntax and
using an explicit call to supply_y.  What's the problem?

As far of the subject of the thread goes, though, I don't see how this
can help.  The problem isn't that there's no way to refer to the
decorated function, because there is a reference to it (the argument
to the actual decorator, eg, the third foo in "foo = deco(foo)(foo)"
which is an "anonymous reference" in the decorator implementation in
CPython).  The problem isn't referring to the name of the function,
either; we don't care what the name is here.




More information about the Python-ideas mailing list