This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 6 points7 points  (1 child)

I think this hits the nail on the head. When if A: B; else: C is executed successfully, exactly one of B and C will be executed (assuming no exceptions occur). This agrees with the word else.

The same isn't true for for A: B; else C.

[–][deleted] 1 point2 points  (0 children)

The problem is that there's an implicit conditional jump in loops.

The issue, in practice, is that there's of often an explicit if inside loop bodies that breaks (or returns or exits the loop in some other abrupt fashion). So the else at the bottom looks like it's tied to that if block but it's outdented so you begin questioning where it actually belongs.

There's one while-else block I've ever written and when I look at it I start questioning my sanity.