(An Unofficial) Python Tutorial Wiki

putting the community back in "maintained by the community"

3tj9

The section describing User-defined Exceptions should begin with the simplest possible example and only later on show more elaborate ones. I recall when learning Python it took me a while to realize that I did not need to override any methods to utilize custom exceptions. For example:

>>> class MyError(Exception):
...     pass
...     
>>> raise MyError, 'Something bad happened'
Traceback (most recent call last):
  File "<input>", line 1, in ?
MyError: Something bad happened