is it possible to improve traceback messages ?

Sion Arrowsmith siona at chiark.greenend.org.uk
Tue Aug 7 09:41:23 EDT 2007


Zentrader  <zentraders at gmail.com> wrote:
>This is the "standard" way AFAIK
>.try :
>.   some_process
>.except :
>.   import trackback, sys
>.   et, ev, tb = sys.exc_info()
>.   while tb :
>.        co = tb.tb_frame.f_code
>.        print "Filename = " + str(co.co_filename)
>.        print  "Error Line # = " + str(traceback.tb_lineno(tb))
>.        tb = tb.tb_next
>.   print "error type = ", et
>.   print "error var name  = ", ev

Personally, I find:

try:
    some_process
except:
    import traceback
    traceback.print_exc()
    raise

just as informative and much easier to write.

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
   "Frankly I have no feelings towards penguins one way or the other"
        -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump



More information about the Python-list mailing list