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 unnecessary use of `eval()` is evil. You can spell it this way:
z = [lambda x=i: x for i in range(10)]
The `x` is a local name and default values are evaluated and bound when
the function is created.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list