1. Computing

Beginning Python: Exceptions, Errors, and Warnings

From , former About.com Guide

1 of 8

What is an Exception?

More often than not, a program is written to address a certain problem. It may be as simple as converting certain kinds of British spelling to American spelling, or vice versa. Or it may be working with hundreds of internet spiders throughout the Web or tracking and processing millions of financial transactions. Of the latter two, Google uses Python for the first and the New York Stock Exchange (NYSE) does the second every day.

Any publisher who has authors in Australia, New Zealand, Canada or elsewhere in the former British Commonwealth must do the first task whenever they bring a book to the US markets. If their conversion program expects only plain English (ASCII) it will be in trouble. The program will inevitably encounter an foreign phrase or other unexpected piece of text. It will then throw an error [read: crash].

Whenever Python throws an error on a program that is programmed with proper Python syntax, it has hit upon an exception. While your data may vary, you can program Python to expect variability in the data. Using the information presented in this tutorial, your Python programs will cope quite nicely and deal with failures in the way that you decide.

Other tutorials in this series: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8

  1. About.com
  2. Computing
  3. Python
  4. Beginning Python
  5. Python Exceptions - Beginning Python: Exceptions, Errors, and Warnings

©2013 About.com. All rights reserved.