[Tutor] What is in the traceback object

Ertl, John john.ertl at fnmoc.navy.mil
Tue Feb 8 19:42:27 CET 2005


Danny,

That is great...every time I have a problem someone has already solved
it...the other problem is finding that solution...Thanks again.

John Ertl
-----Original Message-----
From: Danny Yoo [mailto:dyoo at hkn.eecs.berkeley.edu]
Sent: Tuesday, February 08, 2005 10:39
To: Ertl, John
Cc: 'tutor at python.org'
Subject: Re: [Tutor] What is in the traceback object


On Tue, 8 Feb 2005, Ertl, John wrote:

> I have a bit of code that uses a module and I am trying to get more info
> on the error.
>
> I am using this bit of code:
>
>     try:
>         rhfill    = Ngl.contour(wks,rhisobar,rh_res)
>     except:
>         execType,value,tracebak = sys.exc_info()[:3]
>         print execType
>         print value
>         print tracebak
>
> In the log file I get this:
>
> exceptions.SystemError
> error return without exception set
> <traceback object at 0xb6cf2c84>
>
> How do I get the actual traceback so I can read it?


Hi John,


You can use the 'traceback' module:

    http://www.python.org/doc/lib/module-traceback.html

Use the traceback.print_exc() function within the except block: it'll
automatically pull information from sys.exc_info() for you:

######
try:
    rhfill    = Ngl.contour(wks,rhisobar,rh_res)
except:
    traceback.print_exc()
######


Best of wishes to you!


More information about the Tutor mailing list