All:
def a(p):
return p+1
def gen(func, k=100):
l= []
for x in range(k):
temp = ("%s_with_parameter_%s" %(func.__name__, x), lambda: func(x))
# maybe this will be more clear to explain my quetion:
# i want to get list/dict which can bind self-defined string and function together
l.append(temp)
return l
l = gen(a, 100)
for x in range(len(l)):
l[x][1]()
100
100
100
100
100
100
100
100
...I suppose output will be a 1 to 101
print out, but it shows a 100
list.
May I get help for this snippet here?
Thanks!