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
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
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
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
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