I think the above is a good idea of what's wrong with python (and Go), because in your example the list comp is evaluated in what seems to be this order:
FOURTH-> print([THIRD-> v*v for v in FIRST-> reversed(a) if SECOND-> v*v % 2 == 0])
Which is all over the place. I'd rather see:
a = [1, 2, 3, 4]
a = reversed(a)
a = [v*v for v in a]
a = [w for w in a if a % 2 == 0]
print(a)
I often use generator expressions for the intermediate values (so I don't allocate a new list for each step), but I find this to be much more readable.
libria|1 year ago
alfons_foobar|1 year ago
I often use generator expressions for the intermediate values (so I don't allocate a new list for each step), but I find this to be much more readable.