If I make two lists of functions:
def makeFun(i): return lambda: i a = [makeFun(i) for i in range(10)] b = [lambda: i for i in range(10)]
One set of functions (a) operates on the argument passed and the other (b) operates on a global variable which is then set to 9. Check the disassembly:
>>> import dis >>> dis.dis(a[2]) 1 0 LOAD_DEREF 0 (i) 3 RETURN_VALUE >>> dis.dis(b[2]) 1 0 LOAD_GLOBAL 0 (i) 3 RETURN_VALUE >>>