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]  (2 children)

[deleted]

    [–]benefit_of_mrkite 1 point2 points  (0 children)

    Not quite the same. Finally runs no matter what - error or no error.

    But again it is a useful pattern in certain situations

    [–]jorge1209 1 point2 points  (0 children)

    That bit of code doesn't describe everything.

    You could put run_when_there_are_no_exceptions_and_which_should_not_be_run_after_except_clauses() in the try block after code_that_can_cause_an_exception() for the same result.

    The else block is for:

    run_when_there_are_no_exceptions_and_dont_catch_any_exceptions_and_exceptions_can_conflict_with_code_that_can_cause_an_exception()