Skip to content

Commit 7142df5

Browse files
shanavas786terryjreedy
authored andcommitted
bpo-39431: Also mention nonlocal in assignment quirk (GH-17375)
1 parent 99e6c26 commit 7142df5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Doc/tutorial/classes.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ language definition is evolving towards static name resolution, at "compile"
143143
time, so don't rely on dynamic name resolution! (In fact, local variables are
144144
already determined statically.)
145145

146-
A special quirk of Python is that -- if no :keyword:`global` statement is in
147-
effect -- assignments to names always go into the innermost scope. Assignments
148-
do not copy data --- they just bind names to objects. The same is true for
149-
deletions: the statement ``del x`` removes the binding of ``x`` from the
146+
A special quirk of Python is that -- if no :keyword:`global` or :keyword:`nonlocal`
147+
statement is in effect -- assignments to names always go into the innermost scope.
148+
Assignments do not copy data --- they just bind names to objects. The same is true
149+
for deletions: the statement ``del x`` removes the binding of ``x`` from the
150150
namespace referenced by the local scope. In fact, all operations that introduce
151151
new names use the local scope: in particular, :keyword:`import` statements and
152152
function definitions bind the module or function name in the local scope.

0 commit comments

Comments
 (0)