class Foo(object): def __init__(self): self.__call__ = self.__realcall__ def __realcall__(self): return 'foo' class Bar(object): def __init__(self): self.__call__ = self.__realcall__ def __realcall__(self): return 'bar' def __call__(self): return self.__call__() try: print 'Foo:' print Foo()() except: import traceback traceback.print_exc() print 'Bar:', Bar()()