else clause to be run if no exceptions occurred that isthe finally clause could not be mixed with except and else this was partly because of implementation issuesand partly because the meaning of mixing the two seemed obscure--catching and recovering from exceptions seemed disjoint concept from performing cleanup actions in python and laterthoughthe two statements have merged todaywe can mix finallyexceptand else clauses in the same statement--in part because of similar utility in the java language that iswe can now write statement of this formtrymain-action except exception handler except exception handler elseelse-block finallyfinally-block merged form catch exceptions no-exception handler the finally encloses all else the code in this statement' main-action block is executed firstas usual if that code raises an exceptionall the except blocks are testedone after anotherlooking for match to the exception raised if the exception raised is exception the handler block is executedif it' exception handler is runand so on if no exception is raisedthe else-block is executed no matter what' happened previouslythe finally-block is executed once the main action block is complete and any raised exceptions have been handled in factthe code in the finally-block will be run even if there is an error in an exception handler or the else-block and new exception is raised as alwaysthe finally clause does not end the exception--if an exception is active when the finally-block is executedit continues to be propagated after the finallyblock runsand control jumps somewhere else in the program (to another tryor to the default top-level handlerif no exception is active when the finally is runcontrol resumes after the entire try statement the net effect is that the finally is always runregardless of whetheran exception occurred in the main action and was handled an exception occurred in the main action and was not handled no exceptions occurred in the main action new exception was triggered in one of the handlers againthe finally serves to specify cleanup actions that must always occur on the way out of the tryregardless of what exceptions have been raised or handled unified try/except/finally