Description
Python's closures are late binding. This means that names within closures are looked up at the time the inner function is called.
I propose this wording be changed to
Python's closures are late binding. This means that the values of variables used in closures are looked up at the time the inner function is called.
The difference is illustrated by this code.
s = 'global'
def foo():
s = 'nonlocal'
def bar():
print(s)
del s
bar()
foo()
Looking up the name at call time could be taken to mean that the variable to print is decided at call time. But in fact the variable (cell) is fixed at the time bar() is compiled, and it is just the value that is subject to change. In this case, the value is deleted and so NameError is raised.
(Yeah, I'm being a bit pedantic. I guess I'm really just testing out using github and the issue tracker. Nice guide. :) )