Skip to content

Commit cee95fe

Browse files
miss-islingtonpbhd
andauthored
bpo-36739: Update controlflow.rst (GH-12983)
in addition to global-statement also mention nonlocal-statement (in the paragraph describing access to variables which are non local to a function (cherry picked from commit e1f95e7) Co-authored-by: pbhd <[email protected]>
1 parent 3708316 commit cee95fe

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Doc/tutorial/controlflow.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,11 @@ variables of the function. More precisely, all variable assignments in a
279279
function store the value in the local symbol table; whereas variable references
280280
first look in the local symbol table, then in the local symbol tables of
281281
enclosing functions, then in the global symbol table, and finally in the table
282-
of built-in names. Thus, global variables cannot be directly assigned a value
283-
within a function (unless named in a :keyword:`global` statement), although they
284-
may be referenced.
282+
of built-in names. Thus, global variables and variables of enclosing functions
283+
cannot be directly assigned a value within a function (unless, for global
284+
variables, named in a :keyword:`global` statement, or, for variables of enclosing
285+
functions, named in a :keyword:`nonlocal` statement), although they may be
286+
referenced.
285287

286288
The actual parameters (arguments) to a function call are introduced in the local
287289
symbol table of the called function when it is called; thus, arguments are

0 commit comments

Comments
 (0)