lambda-funcs problem

dmitrey.kroshko at scipy.org dmitrey.kroshko at scipy.org
Wed Sep 19 07:39:44 EDT 2007


hi all,
I need to create a Python list of lambda-funcs that are dependent on
the number of the ones, for example

F = []
for i in xrange(N):
    F.append(lambda x: x + i)

however, the example don't work - since i in end is N-1 it yields x+
(N-1) for any func.

So what's the best way to make it valid?
Evaluation speed is also very important to me.

Thank you in advance, D.




More information about the Python-list mailing list