Fredrik Lundh <[EMAIL PROTECTED]> wrote:
>Iain King wrote:
>> I'm guessing I'm the one confused here... but I'm confused! What's
>> going on?
>the clauses nest from left to right, not from right to left, so "[x for
>x in y for y in beta]" is equivalent to
>
> out = []
> for x in y:
> for y in beta:
> out.append(x)
And a list comprehension doesn't get a namespace to itself (cf.
generator comprehensions) so "leaks" its variables. Exactly as
above. So the y being iterated over in "for x in y" is the y
from the previous inner iteration ("for y in beta").
--
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
___ | "Frankly I have no feelings towards penguins one way or the other"
\X/ | -- Arthur C. Clarke
her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
--
http://mail.python.org/mailman/listinfo/python-list