functions = [] def make_f(i): def f(): print i return f for i in xrange(10): functions.append(make_f(i))