Defining our own exceptions class Stack: def __init(self): self.stack = [] def pop(self): try: return self.stack.pop() except IndexError: raise "PopEmpty", "pop from empty stack" >>> s = Stack() >>> s.pop() Traceback (innermost last): File "", line 1, in ? s.pop() File "", line 12, in pop raise "PopEmpty", "pop from empty stack" PopEmpty: pop from empty stack Exceptions may also be classes or instances