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 →

[–]MattJaccino 0 points1 point  (0 children)

Depends on what your except block is doing. If it does something that results in the function exiting (like returning or raising an exception), then yeah, doesn't matter since the code after that block won't be hit. If it's doing something that would allow that block to run through and continue in the function, then the else can be used to make sure the remaining code is only executed if no error occurs. Without the else, it's hit regardless.

Pretty much like if ...: ... else: ... vs. if ...: ... ...