Wed 27 Feb 2002

  • Python tricks: Matt Wilson rocks my world. Some piece of code was doing a try … except: pass on a function I wrote way up the stack, making it impossible for me to debug it. He showed me how to use the traceback module to see what wasn’t working.

    def foo(): try: # put code to be debugged here print “1” + 1 except: (type, value, tb) = sys.exc_info() frame = tb.tb_frame.f_back print “function”, frame.f_code.co_name print “file”, frame.f_code.co_filename print “line”, frame.f_lineno traceback.print_exc (None) raise

Leave a Reply

Your email address will not be published. Required fields are marked *