identically tothe prior example in factsyntactic nesting works just like the cases sketched in figure - and figure - the only difference is that the nested handlers are physically embedded in try blocknot coded elsewhere in functions that are called from the try block for examplenested finally handlers all fire on an exceptionwhether they are nested syntactically or by means of the runtime flow through physically separated parts of your codetrytryraise indexerror finallyprint('spam'finallyprint('spam'spam spam traceback (most recent call last)file ""line in indexerror see figure - for graphic illustration of this code' operationthe effect is the samebut the function logic has been inlined as nested statements here for more useful example of syntactic nesting at workconsider the following fileexcept-finally pydef raise ()raise indexerror def noraise()return def raise ()raise syntaxerror for func in (raise noraiseraise )print('func __name__trytryfunc(except indexerrorprint('caught indexerror'finallyprint('finally run'print('this code catches an exception if one is raised and performs finally terminationtime action regardless of whether an exception occurs this may take few moments to digestbut the effect is the same as combining an except and finally clause in single try statement in python and laterpython except-finally py caught indexerror finally run finally run designing with exceptions