O'Reilly logo

Python Essentials by Steven F. Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the try and except statements

When an exception is raised, the ordinary sequential exception of statements stops. The next sequential statement is not executed. Instead, the exception handlers are examined to find an except clause which matches the given exception's class. This search proceeds down the call stack from the current function to the function which called it. If an except clause is found which matches the exception, then ordinary sequential execution resumes in that except clause. When the except clause finishes, the try statement is also finished. From there, the normal sequential statement execution continues after the try statement.

If no except clause matches the given exception, the exception and the traceback information ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required