3 ms·
People who come from math backgrounds often becomes infatuated with complicated list comprehensions when they realize that they can be used as set-builder notat
by bjourne 8y ago
People who come from math backgrounds often becomes infatuated with complicated list comprehensions when they realize that they can be used as set-builder notation. {(x,y) for x in range(10) for y in range(10) if y == 2*x}
- mike00632 8y agoThat looks exactly like my notes from math courses and I'm overjoyed that it's meaningful in Python.
- analog31 8y agoI use stuff like that. But my rule of thumb is that I try and make it readable by breaking it up into multiple lines and using indentation. If I can't make it readable, then I will consider another way of writing it. This is mainly for self preservation, since I'm likely to be the person who has to read it later.