is it possible to improve traceback messages ?

Zentrader zentraders at gmail.com
Mon Aug 6 21:48:31 CEST 2007


On Aug 6, 10:54 am, "Chris Mellon" <arka... at gmail.com> wrote:
> On 8/6/07, Stef Mientki <S.Mientki-nos... at mailbox.kun.nl> wrote:
>
>
>
> > hello,
>
> > Most of time I get an error message, it is sufficient to solve to problem.
> > Sometimes it's not clear to me what the problem is
> > like this one:
>
> >      N = int (log10(self.Value)) + 1
> > TypeError: int() argument must be a string or a number
>
> > In order to solve it, in general I put some print statements,
> > before the line with the problem,
> > printing values and types of all variables.
>
> > I think it would be much more convenient,
> > if the traceback or error exception ( don't know how it works exactly),
> > would print the type and value of all variables and constants used in the last line.
>
> > Can this be done (in a easy way).
>
> See the cgitb module.

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




More information about the Python-list mailing list