Re: why is this different?

2006-12-08 Thread Gabriel Genellina
On 7 dic, 22:53, Schüle Daniel <[EMAIL PROTECTED]> wrote: > In [38]: f = [lambda:i for i in range(10)] > In [39]: ff = map(lambda i: lambda : i, range(10)) > In [40]: f[0]() > Out[40]: 9 > In [41]: f[1]() > Out[41]: 9 > In [42]: ff[0]() > Out[42]: 0 > In [43]: ff[1]() > Out[43]: 1 > > I don't unde

Re: why is this different?

2006-12-08 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Schüle Daniel wrote: > I have two more examples, but now I understand the difference > > In [70]: x = [eval("lambda:i") for i in range(10)] > In [71]: y = [eval("lambda:%i" % i) for i in range(10)] > > I think [71] is most obvious what the programmer intends But unnecess

Re: why is this different?

2006-12-08 Thread Schüle Daniel
Gabriel Genellina schrieb: Gabriel Genellina schrieb: > On 7 dic, 22:53, Schüle Daniel <[EMAIL PROTECTED]> wrote: > >> In [38]: f = [lambda:i for i in range(10)] >> In [39]: ff = map(lambda i: lambda : i, range(10)) >> In [40]: f[0]() >> Out[40]: 9 >> In [41]: f[1]() >> Out[41]: 9 >> In [42]: ff[0

Re: why is this different?

2006-12-08 Thread Gabriel Genellina
On 7 dic, 22:53, Schüle Daniel <[EMAIL PROTECTED]> wrote: > In [38]: f = [lambda:i for i in range(10)] > In [39]: ff = map(lambda i: lambda : i, range(10)) > In [40]: f[0]() > Out[40]: 9 > In [41]: f[1]() > Out[41]: 9 > In [42]: ff[0]() > Out[42]: 0 > In [43]: ff[1]() > Out[43]: 1 > > I don't unde

why is this different?

2006-12-08 Thread Schüle Daniel
Hello snakes :) In [38]: f = [lambda:i for i in range(10)] In [39]: ff = map(lambda i: lambda : i, range(10)) In [40]: f[0]() Out[40]: 9 In [41]: f[1]() Out[41]: 9 In [42]: ff[0]() Out[42]: 0 In [43]: ff[1]() Out[43]: 1 I don't understand why in the first case f[for all i in 0..9]==9 what is diff