triggered when the function tries to run obj[indexpython detects out-of-bounds indexing for sequences and reports it by raising (triggeringthe built-in indexerror exceptionfetcher( traceback (most recent call last)file ""line in file ""line in fetcher indexerrorstring index out of range default handler shell interface because our code does not explicitly catch this exceptionit filters back up to the top level of the program and invokes the default exception handlerwhich simply prints the standard error message by this point in the bookyou've probably seen your share of standard error messages they include the exception that was raisedalong with stack trace-- list of all the lines and functions that were active when the exception occurred the error message text here was printed by python it can vary slightly per releaseand even per interactive shellso you shouldn' rely upon its exact form--in either this book or your code when you're coding interactively in the basic shell interfacethe filename is just ",meaning the standard input stream when working in the idle gui' interactive shellthe filename is ",and source lines are displayedtoo either wayfile line numbers are not very meaningful when there is no file (we'll see more interesting error messages later in this part of the book)fetcher( traceback (most recent call last)file ""line in fetcher( file ""line in fetcher return obj[indexindexerrorstring index out of range default handler idle gui interface in more realistic program launched outside the interactive promptafter printing an error message the default handler at the top also terminates the program immediately that course of action makes sense for simple scriptserrors often should be fataland the best you can do when they occur is inspect the standard error message catching exceptions sometimesthis isn' what you wantthough server programsfor instancetypically need to remain active even after internal errors if you don' want the default exception behaviorwrap the call in try statement to catch exceptions yourselftryfetcher( except indexerrorprint('got exception' exception basics catch and recover