Bug in list comprehensions?
fredrik at pythonware.com
Wed Jun 7 12:39:24 CEST 2006
Iain King wrote:
> I'm guessing I'm the one confused here... but I'm confused! What's
> going on?
reading the documentation may help:
/.../ the elements of the new list are those that would be produced
by considering each of the for or if clauses a block, nesting from left
to right, and evaluating the expression to produce a list element each
time the innermost block is reached.
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:
More information about the Python-list