Nick Coghlan writes:
It isn't quite - the name binding doesn't happen until *after* the decorator chain has been invoked, so the function is anonymous while the decorators are executing.
As I understand the issue here, as far as the decorators are concerned, the reference passed by the decorator syntax should be enough to do any namespace manipulations that are possible in a (non-magic) decorator. Am I missing something? That is, in
the following closure idiom:
def <anon1>(): NAME = EXPR def FUNC(ARGLIST):
surely the FUNC above ...
"""DOC""" nonlocal NAME BODY return FUNC
... doesn't need to be the *same identifier* as the FUNC below?
FUNC = <anon1>()
Isn't magic needed solely to inject the nonlocal statement(s) into the definition of FUNC inside <anon1> at compile-time?