and you reduce the amount of code within the function the types of programs you write will probably influence the amount of exception handling you code as well serversfor instancemust generally keep running persistently and so will likely require try statements to catch and recover from exceptions inprocess testing programs of the kind we saw in this will probably handle exceptions as well simpler one-shot scriptsthoughwill often ignore exception handling completely because failure at any step requires script shutdown catching too muchavoid empty except and exception as mentionedexception handler generality is key design choice python lets you pick and choose which exceptions to catchbut you sometimes have to be careful to not be too inclusive for exampleyou've seen that an empty except clause catches every exception that might be raised while the code in the try block runs that' easy to codeand sometimes desirablebut you may also wind up intercepting an error that' expected by try handler higher up in the exception nesting structure for examplean exception handler such as the following catches and stops every exception that reaches itregardless of whether another handler is waiting for itdef func()tryexcepttryfunc(except indexerrorindexerror is raised in here but everything comes here and diesexception should be processed here perhaps worsesuch code might also catch unrelated system exceptions even things like memory errorsgenuine programming mistakesiteration stopskeyboard interruptsand system exits raise exceptions in python unless you're writing debugger or similar toolsuch exceptions should not usually be intercepted in your code for examplescripts normally exit when control falls off the end of the top-level file howeverpython also provides built-in sys exit(statuscodecall to allow early terminations this actually works by raising built-in systemexit exception to end the programso that try/finally handlers run on the way out and special types of programs can intercept the event because of thisa try with an empty except might unknowingly prevent crucial exitas in the following file (exiter py) related callos _exitalso ends programbut via an immediate termination--it skips cleanup actionsincluding any registered with the atexit module noted earlierand cannot be intercepted with tryexcept or try/finally blocks it is usually used only in spawned child processesa topic beyond this book' scope see the library manual or follow-up texts for details exception design tips and gotchas