This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients Lukas.Petru, eric.araujo, rhettinger, terry.reedy
Date 2011-05-25.18:32:00
SpamBayes Score 3.1664214e-07
Marked as misclassified No
Message-id <1306348321.32.0.436383209393.issue12165@psf.upfronthosting.co.za>
In-reply-to
Content
Another problem with the current text is that it fails to exclude enclosing class scopes, and I had to test to be sure they were., and some of the phrasing strikes me as awkward. Here is a possible rewrite.

"When the definition of a function is nested (enclosed) within the definitions of other functions, its nonlocal scopes are the local scopes of the enclosing functions. The nonlocal statement causes the listed identifiers to refer to names previously bound in nonlocal scopes. If a name is bound in more than one nonlocal scope, the nearest binding is used. If a name is not bound in any nonlocal scope, or if there is no nonlocal scope, a SyntaxError is raised.

Except for the requirement that the listed indentifiers be previously bound, the nonlocal statement is similar to the global statement. It applies to the entire function body, so it cannot follow any local bindings of the same names."

My main change is to first unambiguously define nonlocal scopes and continue from there.
History
Date User Action Args
2011-05-25 18:32:01terry.reedysetrecipients: + terry.reedy, rhettinger, eric.araujo, Lukas.Petru
2011-05-25 18:32:01terry.reedysetmessageid: <1306348321.32.0.436383209393.issue12165@psf.upfronthosting.co.za>
2011-05-25 18:32:00terry.reedylinkissue12165 messages
2011-05-25 18:32:00terry.reedycreate