3 ms·
While this is a great capability to have, the tendency to have an indented “if” preceding a not-indented “else” just always seems like somebody might have made
by makecheck 8y ago
While this is a great capability to have, the tendency to have an indented “if” preceding a not-indented “else” just always seems like somebody might have made a mistake.
I would rather something that captures the loop state itself as an operable object, such as:
with for as loop:
for x in my_list:
...
if not loop.broken:
...
- sooheon 8y agoInteresting how people's intuitions differ. For me hiding yet another . method that requires discovery is more burden on the human. I'd rather reach for map/filter => processing.
- Mangalor 8y agoSeconded
- deleted 8y ago[deleted]
- fyi1183 8y agoThe if you're talking about ends in a break. To me and many others, having an else associated to an if that ends in break/continue/return is a code smell, because it misleadingly suggests that there are two possible paths of control flow that reach the code after the if/else, when in reality you can only reach that point through the else block.