operation that could possibly go astrayand propagate the results of the tests as your programs rundostuff( program if (dofirstthing(=errordetect errors everywhere return erroreven if not handled here if (donextthing(=errorreturn errorreturn dolastthing()main(if (dostuff(=errorbadending()else goodending()in factrealistic programs often have as much code devoted to error detection as to doing actual work but in pythonyou don' have to be so methodical (and neurotic!you can instead wrap arbitrarily vast pieces of program in exception handlers and simply write the parts that do the actual workassuming all is normally welldef dostuff()dofirstthing(donextthing(dolastthing(python code we don' care about exceptions hereso we don' need to detect them if __name__ ='__main__'trydostuff(this is where we care about resultsexceptso it' the only place we must check badending(elsegoodending(because control jumps immediately to handler when an exception occursthere' no need to instrument all your code to guard for errorsand there' no extra performance overhead to run all the tests moreoverbecause python detects errors automaticallyyour code often doesn' need to check for errors in the first place the upshot is that exceptions let you largely ignore the unusual cases and avoid error-checking code that can distract from your program' goals summary and that is the majority of the exception storyexceptions really are simple tool to summarizepython exceptions are high-level control flow device they may be raised by pythonor by your own programs in both casesthey may be ignored (to trigger the default error message)or caught by try statements (to be processed by your summary