In message <[email protected]>, Michal Ostrowski wrote:
> def MakeLambdaBad():
> a = []
> for x in [1,2]:
> a.append(lambda q: x + q)
> return a
Here's another form that should work:
def MakeLambdaGood2() :
a = []
for x in [1, 2] :
a.append((lambda x : lambda q : x + q)(x))
return a
It's all a question of scope.
--
http://mail.python.org/mailman/listinfo/python-list
