This function tells you where the exception occured:
#!/usr/bin/env python import sys import traceback def func(): try: a = 1/0 except Exception as e: print( " ", sys.exc_info()[0]) print( " ", e) exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_tb(exc_traceback, limit=None, file=sys.stdout) func()
The output:
<type 'exceptions.ZeroDivisionError'> integer division or modulo by zero File "t1.py", line 7, in func a = 1/0