next up previous contents
Next: Tracebacks Up: Exceptions Previous: Exceptions   Contents


One of the basic principles of Python mentioned in Chapter 1 was the idea of exception handling. Unlike many languages, which leave the business of error handling to the programmer using the language, Python handles errors in a consistent way - when an error is encountered, Python prints a descriptive message, and terminates execution. But beyond this default behaviour, Python provides a simple way to trap these errors and either ignore them, fix them, or decide that program termination really is the best idea. The basic notion of the try/except clause has already been introduced; in this chapter we'll discuss its use more thoroughly, as well as look at how to create new exceptions, and how to raise exceptions within your programs.

Phil Spector 2003-11-12