mirror of
https://github.com/python/cpython.git
synced 2025-12-07 17:57:56 +00:00
#4549: Mention nonlocal statement in tutorial section about scoping.
This commit is contained in:
parent
6d204bf9b6
commit
fed7d80988
1 changed files with 5 additions and 6 deletions
|
|
@ -119,12 +119,11 @@ contains the current module's global names; and the outermost scope (searched
|
||||||
last) is the namespace containing built-in names.
|
last) is the namespace containing built-in names.
|
||||||
|
|
||||||
If a name is declared global, then all references and assignments go directly to
|
If a name is declared global, then all references and assignments go directly to
|
||||||
the middle scope containing the module's global names. Otherwise, all variables
|
the middle scope containing the module's global names. To rebind variables
|
||||||
found outside of the innermost scope are read-only (an attempt to write to such
|
found outside of the innermost scope, the :keyword:`nonlocal` statement can be
|
||||||
a variable will simply create a *new* local variable in the innermost scope,
|
used; if not declared nonlocal, those variable are read-only (an attempt to
|
||||||
leaving the identically named outer variable unchanged).
|
write to such a variable will simply create a *new* local variable in the
|
||||||
|
innermost scope, leaving the identically named outer variable unchanged).
|
||||||
.. XXX mention nonlocal
|
|
||||||
|
|
||||||
Usually, the local scope references the local names of the (textually) current
|
Usually, the local scope references the local names of the (textually) current
|
||||||
function. Outside functions, the local scope references the same namespace as
|
function. Outside functions, the local scope references the same namespace as
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue