velopment termination actions as you'll seethe try/finally statement allows you to guarantee that required closing-time operations will be performedregardless of the presence or absence of exceptions in your programs the newer with statement offers an alternative in this department for objects that support it unusual control flows finallybecause exceptions are sort of high-level and structured "go to,you can use them as the basis for implementing exotic control flows for instancealthough the language does not explicitly support backtrackingyou can implement it in python by using exceptions and bit of support logic to unwind assignments there is no "go tostatement in python (thankfully!)but exceptions can sometimes serve similar rolesa raisefor instancecan be used to jump out of multiple loops we saw some of these roles briefly earlierand will study typical exception use cases in action later in this part of the book for nowlet' get started with look at python' exception-processing tools exceptionsthe short story compared to some other core language topics we've met in this bookexceptions are fairly lightweight tool in python because they are so simplelet' jump right into some code default exception handler suppose we write the following functiondef fetcher(objindex)return obj[indexthere' not much to this function--it simply indexes an object on passed-in index in normal operationit returns the result of legal indexx 'spamfetcher( 'mlike [ but true backtracking is not part of the python language backtracking undoes all computations before it jumpsbut python exceptions do notvariables assigned between the time try statement is entered and the time an exception is raised are not reset to their prior values even the generator functions and expressions we met in don' do full backtracking--they simply respond to next(grequests by restoring state and resuming for more on backtrackingsee books on artificial intelligence or the prolog or icon programming languages exceptionsthe short story