Skip to content

Commit 48256e1

Browse files
authored
Merge pull request satwikkansal#247 from abdnh/patch-1
Fix typo
2 parents 048a620 + de4b851 commit 48256e1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ The values of `x` were different in every iteration prior to appending `some_fun
10271027
* When defining a function inside a loop that uses the loop variable in its body, the loop function's closure is bound to the *variable*, not its *value*. The function looks up `x` in the surrounding context, rather than using the value of `x` at the time the function is created. So all of the functions use the latest value assigned to the variable for computation. We can see that it's using the `x` from the surrounding context (i.e. *not* a local variable) with:
10281028
```py
10291029
>>> import inspect
1030-
>>> inspect.getclosurevals(funcs[0])
1030+
>>> inspect.getclosurevars(funcs[0])
10311031
ClosureVars(nonlocals={}, globals={'x': 6}, builtins={}, unbound=set())
10321032
```
10331033
Since `x` is a global value, we can change the value that the `funcs` will lookup and return by updating `x`:

0 commit comments

Comments
 (0)