by makecheck · 8y ago · 0 comments
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:
...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.