2 ms·
I find the order of iteration in Python for comprehensions totally confusing every time. If you want to convert: for a in x: pass into a comprehension, yo
by lmm 10y ago
I find the order of iteration in Python for comprehensions totally confusing every time. If you want to convert:
for a in x: pass
into a comprehension, you write:
[pass for a in x]
Simple, right? So to convert
for a in x: for b in y: pass
I obviously write:
[pass for b in y for a in x]
Bzzt. Nope, you have to write it in middle-endian order to get the same behaviour.