Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Strange line of Python. Parent comment
For what it's worth, it's pretty easy to "unwrap" a Python listcomp: it's a sequence of nested loops, nested tests and a mapping.
result = [mapping for iteration1 for iteration2 for iteration3 if test1 if test1]
result = [] for iteration1 for iteration2 for iteration3 if test1 if test2 result.push(mapping)
There are no comments on this comment yet.
For what it's worth, it's pretty easy to "unwrap" a Python listcomp: it's a sequence of nested loops, nested tests and a mapping.
is equivalent (modulo some scoping interaction with the code outside it) to Apart from the final mapping, listcomps are executed strictly left to right, an evaluation can use anything produced to the "left" of it.