Skip to content

Commit

Permalink
Clarifying nonlocal doc: SyntaxError is raised if nearest enclosing s…
Browse files Browse the repository at this point in the history
…cope is global (python#114009)

Co-authored-by: Jelle Zijlstra <[email protected]>
  • Loading branch information
quazi-irfan and JelleZijlstra authored Apr 21, 2024
1 parent 15fbd53 commit 1558d99
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Doc/reference/executionmodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ namespace. Names are resolved in the top-level namespace by searching the
global namespace, i.e. the namespace of the module containing the code block,
and the builtins namespace, the namespace of the module :mod:`builtins`. The
global namespace is searched first. If the names are not found there, the
builtins namespace is searched. The :keyword:`!global` statement must precede
all uses of the listed names.
builtins namespace is searched next. If the names are also not found in the
builtins namespace, new variables are created in the global namespace.
The global statement must precede all uses of the listed names.

The :keyword:`global` statement has the same scope as a name binding operation
in the same block. If the nearest enclosing scope for a free variable contains
Expand Down

0 comments on commit 1558d99

Please sign in to comment.