I currently use this structure for capturing and recording my exception handling
1. import sys 2. 3. def break_python(): 4. test1 = 1/0 5. 6. def main(): 7. #All main program functionality is included in this section 8. break_python() 9. 10. if __name__ == "__main__": 11. try: 12. main() 13. except Exception as e: 14. print dir(e) 15. print e.message 16. type1,details,tb = sys.exc_info_() 17. print type1 18. print details 19. print tb 20. line_no = tb.tb_lineno 21. print "Line # " + str(line_no) 22. print "Failed to run program" When I run this as my primary program structure everything works however the line number will print as line 12 corresponding to the main() function call when I really want it to point to the function and line number of the individual error, in this case line 4 under function break_python()