# lib.py class Bads(Exception): class Bad1(Bads): pass class Bad2(Bads): pass def func1(): ... raise Bad1(99, 'spam.txt') def func2(): ... raise Bad2(42, 'input') -------------------------- # client.py import lib try: lib.func1() except Bads as X: print X.args[0], X.args[1]