> This is caused by the scoping rules for Python's lambdas and list
> comprehensions. See the question and answer here for an
> explanation:http://stackoverflow.com/questions/139819/why-results-of-map-and-list...
>
> --Mike
...ok, so, a way to write it would be
b = [lambda x,u=i:u for i in ran
Hello,
On Thu, Jan 29, 2009 at 1:46 AM, martin Campos Pinto
wrote:
> I get 0 (which is fine), now when I type
>
> b = [lambda x:i for i in range(2)]
> b[0](0)
>
> I get 1 ... There must be a simple explanation for this but I can't
> figure it out. What's wrong ?
This is caused by the scoping ru