in this code:
results = []
for i in [1, 2, 3, 4]:
    def inner(y):
        return i
    results.append(inner)
for i in results:
    print i(None)  
the output is "function inner at 0x107dea668"
if i change i to other letter, for example:
results = []
for i in [1, 2, 3, 4]:
    def inner(y):
        return i
    results.append(inner)
for j in results:
    print j(None)
the output is "4"
Answer
results = []
for i in [1, 2, 3, 4]:
    def inner(y):
        print "in inner:%s " % id(i)
        return i
    results.append(inner)
# i -> 4
for i in results:
    # i -> func inner
    print "i: %s" % i
    print "in loop: %s " % id(i)
    # func inner <===>  A
    # i == A  ->  return i -> return A, so when call funtion inner, will return itself
    # print "call: %s" % i(None)
    print "call: %s" % i(None)(None)(None)
    print "------------------------------"
i: function inner at 0x101344d70
in loop: 4315172208
in inner:4315172208
in inner:4315172208
in inner:4315172208
call: function inner at 0x101344d70  
i: function inner at 0x101344de8
in loop: 4315172328
in inner:4315172328
in inner:4315172328
in inner:4315172328
call: function inner at 0x101344de8  
i: function inner at 0x101344e60
in loop: 4315172448
in inner:4315172448
in inner:4315172448
in inner:4315172448
call: function inner at 0x101344e60   
i: function inner at 0x101344ed8
in loop: 4315172568
in inner:4315172568
in inner:4315172568
in inner:4315172568
call: function inner at 0x101344ed8  
 
     
     
    

