Skip to content
Advertisement

Tag: try-finally

Why do we need the “finally” clause in Python?

I am not sure why we need finally in try…except…finally statements. In my opinion, this code block is the same with this one using finally: Am I missing something? Answer It makes a difference if you return early: Compare to this: Other situations that can cause differences: If an exception is thrown inside the except block. If an exception is

Advertisement