Understanding exceptions
The word exception is loaded. The definition seems clear: exceptions are exceptional. I'll say, in Python at least, this definition is simply not true. A normal Python program may handle and raise any number of exceptions as it hums along quite nicely.
Consider the Pythonic idiom we have already pointed out multiple times: Easier to Ask Forgiveness than Permission. It is usually expressed as follows:
try: spam.eggs() except AttributeError: spam.ham()
The preceding code is preferred over the following code, which uses a Look Before You Leap style:
if hasattr(spam, 'eggs'): spam.eggs() else: spam.ham()
There is nothing exceptional about exceptions in the first example. Describing them as exceptional is more accurate when describing how they behave rather than how they are used.
I prefer the following definition:
"Exceptions are a form of (exceptional) flow control."
To illustrate that definition, consider the following lines of code:
if spam: for i in xrange...