Hi Yury,
This is happening because the Python lambda does not create a real closure. It only captures the scope, and then does lazy evaluation of the variables. What that means is, if you are attempting to create a closure over variables in a loop, what you get is a capture of the loop scope, and then when the lambda actually evaluates, the loop variable is then evaluated. The last value of the loop variable is 4, so all of your callbacks end up using the value 4.
From a general standpoint (not applicable to your case) you can fix lambda usage by making it take an argument:
fn = lambda i: blah(i)
fn(i)
This means the lambda has to be passed the argument instead of capturing one from the scope. But in your case, you can't use that.
You can fix your lambda, by using the known "double lambda" trick:
c=(lambda i: lambda x:blah(10*i))(i)
This creates a lambda that takes an arg, and then returns a lambda that contains a closure over the outer lambda function. Then we call it with our counter variable, so it gets properly captured. This, as you can tell, is ugly. So best just use "functools.partial":
c=functools.partial(blah, i)
But you will find here, that because maya always wants to pass other arguments to the callback, you would have to modify blah() to accept extra args. So you can use a mixture of partial() and lambda:
c=functools.partial(lambda i, *args: blah(i) , i)
Justin