[Python-checkins] bpo-39431: Also mention nonlocal in assignment quirk (GH-17375)
Terry Jan Reedy
webhook-mailer at python.org
Thu Jan 23 13:09:42 EST 2020
https://github.com/python/cpython/commit/7142df5ea23b4ce0efb72746b4b3b65414e8dcb1
commit: 7142df5ea23b4ce0efb72746b4b3b65414e8dcb1
branch: master
author: Shanavas M <shanavas.m2 at gmail.com>
committer: Terry Jan Reedy <tjreedy at udel.edu>
date: 2020-01-23T13:09:21-05:00
summary:
bpo-39431: Also mention nonlocal in assignment quirk (GH-17375)
files:
M Doc/tutorial/classes.rst
diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst
index 0c0dca99f21f2..f781fecf832f0 100644
--- a/Doc/tutorial/classes.rst
+++ b/Doc/tutorial/classes.rst
@@ -143,10 +143,10 @@ language definition is evolving towards static name resolution, at "compile"
time, so don't rely on dynamic name resolution! (In fact, local variables are
already determined statically.)
-A special quirk of Python is that -- if no :keyword:`global` statement is in
-effect -- assignments to names always go into the innermost scope. Assignments
-do not copy data --- they just bind names to objects. The same is true for
-deletions: the statement ``del x`` removes the binding of ``x`` from the
+A special quirk of Python is that -- if no :keyword:`global` or :keyword:`nonlocal`
+statement is in effect -- assignments to names always go into the innermost scope.
+Assignments do not copy data --- they just bind names to objects. The same is true
+for deletions: the statement ``del x`` removes the binding of ``x`` from the
namespace referenced by the local scope. In fact, all operations that introduce
new names use the local scope: in particular, :keyword:`import` statements and
function definitions bind the module or function name in the local scope.
More information about the Python-checkins
mailing list