summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-12-05 18:06:58 (GMT)
committerGeorg Brandl <georg@python.org>2008-12-05 18:06:58 (GMT)
commitfed7d80988522d4ffa947912a55d4474e0bda12e (patch)
tree34d05608e1173631d55a87ed3fe79c1a9cb6e241
parent6d204bf9b6ab4166c2ebcde5c17f615105748d6e (diff)
downloadcpython-fed7d80988522d4ffa947912a55d4474e0bda12e.zip
cpython-fed7d80988522d4ffa947912a55d4474e0bda12e.tar.gz
cpython-fed7d80988522d4ffa947912a55d4474e0bda12e.tar.bz2
#4549: Mention nonlocal statement in tutorial section about scoping.
-rw-r--r--Doc/tutorial/classes.rst11
1 files changed, 5 insertions, 6 deletions
diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst
index 5831f6c..d6e8ca1 100644
--- a/Doc/tutorial/classes.rst
+++ b/Doc/tutorial/classes.rst
@@ -119,12 +119,11 @@ contains the current module's global names; and the outermost scope (searched
last) is the namespace containing built-in names.
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
-found outside of the innermost scope are read-only (an attempt to 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
+the middle scope containing the module's global names. To rebind variables
+found outside of the innermost scope, the :keyword:`nonlocal` statement can be
+used; if not declared nonlocal, those variable are read-only (an attempt to
+write to such a variable will simply create a *new* local variable in the
+innermost scope, leaving the identically named outer variable unchanged).
Usually, the local scope references the local names of the (textually) current
function. Outside functions, the local scope references the same namespace as