Custom exceptions -- inherit from exceptions.Exception?

Paul Miller pwmiller1 at
Wed Nov 12 07:59:08 CET 2003

Is there any particular good reason to inherit from
exceptions.Exception?  I've never seen any code that depends on what
the base class(es) of a raised exception is (are).

My use case is in a game I am writing.  The code for my Game class
contains the following:

class Game (object):

    def start (self):
        except IndexError:
            raise NotEnoughPlayers

where NotEnoughPlayers is really just an empty classic class suitable
for raising.  Is there any benefit to importing exceptions and
inheriting from exceptions.Exception, other than maybe theoretical


More information about the Python-list mailing list