[Python-checkins] bpo-36739: Update controlflow.rst (GH-12983)
Miss Islington (bot)
webhook-mailer at python.org
Tue May 28 23:48:17 EDT 2019
https://github.com/python/cpython/commit/cee95fe1825dfeb52d7074c8209b5884a079f06c
commit: cee95fe1825dfeb52d7074c8209b5884a079f06c
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-05-28T20:48:12-07:00
summary:
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 e1f95e77e0647aff602e0660ba3c282b71045875)
Co-authored-by: pbhd <p-bauer-schriesheim at t-online.de>
files:
M Doc/tutorial/controlflow.rst
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst
index ed42e2baaf3e..c3ce1205e52e 100644
--- a/Doc/tutorial/controlflow.rst
+++ b/Doc/tutorial/controlflow.rst
@@ -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
More information about the Python-checkins
mailing list