while moreTests(): try: runNextTest() except IndexError: xxx except TypeError: yyy except (E1, E2, E3): zzz except: import sys print sys.exc_info() import traceback traceback.print_exc(open('log.txt', 'a')) else: print 'passed...' finally: fff