We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
2 parentsc7f1da2 +e1b5968 commit00006a9Copy full SHA for 00006a9
docs/writing/gotchas.rst
@@ -128,11 +128,12 @@ What Does Happen
128
129
Five functions are created, but all of them just multiply ``x`` by 4.
130
131
-Python's closures are *late binding*. This means that names within closures are
132
-looked up at the time the inner function is *called*.
+Python's closures are *late binding*.
+This means that the values of variables used in closures are looked
133
+up at the time the inner function is called.
134
135
Here, whenever *any* of the returned functions are called, the value of ``i``
-is looked up in the surrounding scope at call time, when bythen the loop has
136
+is looked up in the surrounding scope at call time. Bythen, the loop has
137
completed and ``i`` is left with its final value of 4.
138
139
What's particularly nasty about this gotcha is the seemingly prevalent