I found this bit of code in a module I am working on:
l = opaque_function()
thingys = [x for y in l for x in y]
I can\'t read this. By expe
From the list displays documentation:
When a list comprehension is supplied, it consists of a single expression followed by at least one
for
clause and zero or morefor
orif
clauses. In this case, the elements of the new list are those that would be produced by considering each of thefor
orif
clauses a block, nesting from left to right, and evaluating the expression to produce a list element each time the innermost block is reached.
Thus, your expression can be rewritten as:
thingys = []
for y in l:
for x in y:
thingys.append(x)