]> granicus.if.org Git - python/commitdiff
bpo-36739: Update controlflow.rst (GH-12983)
authorpbhd <p-bauer-schriesheim@t-online.de>
Wed, 29 May 2019 03:38:03 +0000 (05:38 +0200)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 29 May 2019 03:38:03 +0000 (20:38 -0700)
in addition to global-statement also mention nonlocal-statement
(in the paragraph describing access to variables which are non local to a function

Doc/tutorial/controlflow.rst

index 813b7ca93c72907fd4b1efa4049e59ca691980a7..81a28a6e53257f24e5a3837df90fcdf1f59f91b1 100644 (file)
@@ -279,9 +279,11 @@ variables of the function.  More precisely, all variable assignments in a
 function store the value in the local symbol table; whereas variable references
 first look in the local symbol table, then in the local symbol tables of
 enclosing functions, then in the global symbol table, and finally in the table
-of built-in names. Thus, global variables cannot be directly assigned a value
-within a function (unless named in a :keyword:`global` statement), although they
-may be referenced.
+of built-in names. Thus, global variables and variables of enclosing functions
+cannot be directly assigned a value within a function (unless, for global
+variables, named in a :keyword:`global` statement, or, for variables of enclosing
+functions, named in a :keyword:`nonlocal` statement), although they may be
+referenced.
 
 The actual parameters (arguments) to a function call are introduced in the local
 symbol table of the called function when it is called; thus, arguments are