4 ms·
You can in fact factor out expressions in list comprehensions, like: [foo(y, y) for x in xs for y in [f(x)]] Is this Pythonic? Perhaps not, but mainly bec
by abecedarius 8y ago
You can in fact factor out expressions in list comprehensions, like:
[foo(y, y) for x in xs for y in [f(x)]]
Is this Pythonic? Perhaps not, but mainly because multiline list comprehensions are frowned on in general. I think people tend to get too dogmatic about that.