when an exception occursthe interpreter stops executing statements in the try block and looks for an except clause that matches the exception that has occurred if one is foundcontrol is passed to the first statement in the except clause after the except clause is executedcontrol continues with the first statement that appears after the try-except block otherwisethe exception is propagated up to the block of code in which the try statement appeared this code may itself be enclosed in try-except that can handle the exception if an exception works its way up to the top level of program without being caughtthe interpreter aborts with an error message if desireduncaught exceptions can also be passed to user-defined functionsys excepthook()as described in "python runtime services the optional as var modifier to the except statement supplies the name of variable in which an instance of the exception type supplied to the raise statement is placed if an exception occurs exception handlers can examine this value to find out more about the cause of the exception for exampleyou can use isinstance(to check the exception type one caution on the syntaxin previous versions of pythonthe except statement was written as except exctypevar where the exception type and variable were separated by comma (,in python this syntax still worksbut it is deprecated in new codeuse the as var syntax because it is required in python multiple exception-handling blocks are specified using multiple except clausesas in the following exampletrydo something except ioerror as ehandle / error except typeerror as ehandle type error except nameerror as ehandle name error single handler can catch multiple exception types like thistrydo something except (ioerrortypeerrornameerroras ehandle /otypeor name errors to ignore an exceptionuse the pass statement as followstrydo something except ioerrorpass do nothing (oh wellto catch all exceptions except those related to program exituse exception like thistrydo something except exception as eerror_log write('an error occurred % \nef lib fl ff