% cat safe2.py import sys, traceback def safe(entry, *args): try: apply(entry, args) # catch everything else except: traceback.print_exc() print 'Got', sys.exc_type, sys.exc_value import oops safe(oops.oops) % python safe2.py Traceback (innermost last): File "safe2.py", line 5, in safe apply(entry, args) # catch everything else File "oops.py", line 4, in oops raise MyError, 'world' hello: world Got hello world