Defining an exception class in Python

All you need to do is subclass Exception:

class MyException(Exception):
    pass

If you want additional constructor arguments, call the base class constructor with the first argument:

class MyException(Exception):
    def __init__(self, message, arg):
        super(MyException, self).__init__(message)
        self.arg = arg