finally run traceback (most recent call last)file "except-finally py"line in func(file "except-finally py"line in raise def raise ()raise syntaxerror syntaxerrornone as we saw in as of python except and finally clauses can be mixed in the same try statement thisalong with multiple except clause supportmakes some of the syntactic nesting described in this section unnecessarythough the equivalent runtime nesting is common in larger python programs moreoversyntactic nesting still works todaymay still appear in code written prior to python that you may encountercan make the disjoint roles of except and finally more explicitand can be used as technique for implementing alternative exception-handling behaviors in general exception idioms we've seen the mechanics behind exceptions now let' take look at some of the other ways they are typically used breaking out of multiple nested loops"go toas mentioned at the start of this part of the bookexceptions can often be used to serve the same roles as other languages"go tostatements to implement more arbitrary control transfers exceptionshoweverprovide more structured option that localizes the jump to specific block of nested code in this roleraise is like "go to,and except clauses and exception names take the place of program labels you can jump only out of code wrapped in try this waybut that' crucial feature--truly arbitrary "go tostatements can make code extraordinarily difficult to understand and maintain for examplepython' break statement exits just the single closest enclosing loopbut we can always use exceptions to break out of more than one loop level if neededclass exitloop(exception)pass trywhile truewhile truefor in range( )if raise exitloop print('loop %siprint('loop 'print('loop 'except exitloopprint('continuing'break exits just one level or just passto move on exception idioms