diff options
author | Quazi Irfan <quazirfan@gmail.com> | 2024-04-21 01:42:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-21 01:42:51 (GMT) |
commit | 1558d993166636f371c1003107ec979db6744f21 (patch) | |
tree | 5f3c854c24ebe16cd74874f8c979b89810692f90 | |
parent | 15fbd53ba96be4b6a5abd94ceada684493c36bdd (diff) | |
download | cpython-1558d993166636f371c1003107ec979db6744f21.zip cpython-1558d993166636f371c1003107ec979db6744f21.tar.gz cpython-1558d993166636f371c1003107ec979db6744f21.tar.bz2 |
Clarifying nonlocal doc: SyntaxError is raised if nearest enclosing scope is global (#114009)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
-rw-r--r-- | Doc/reference/executionmodel.rst | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Doc/reference/executionmodel.rst b/Doc/reference/executionmodel.rst index cea3a56..ed50fae 100644 --- a/Doc/reference/executionmodel.rst +++ b/Doc/reference/executionmodel.rst @@ -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 |