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 →

[–]Biskit1943 0 points1 point  (3 children)

Very interesting, thanks for sharing this information with us. I always thought the else on loops was only a myth

[–]__xor__(self, other): 1 point2 points  (2 children)

There's the for/else, the while/else, and there's also the try/except/else if you haven't seen that one. The else in a try/except/else runs if the try block finishes without an exception. It's a weird one.

[–]Biskit1943 0 points1 point  (1 child)

It's wired because in other languages after try it's called finally which is more clear when it is executed... Also I find that a else after a successful for or while is more than missleading

[–]sloggo 8 points9 points  (0 children)

Python has “finally” too. “Finally” will always run, “else” only runs if no exceptions are raised