Faqts : Computers : Programming : Shopping For You : Python : Common Problems : Debugging

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

8 of 8 people (100%) answered Yes
Recently 5 of 5 people (100%) answered Yes

Entry

How do you print the traceback string from an exception?

Jul 1st, 2000 19:19
unknown unknown, Jürgen Hermann


try:
   whatever()
except:
            import traceback, string
            msg = string.join(traceback.format_exception(
                    sys.exc_info()[0], sys.exc_info()[1],
sys.exc_info()[2]), "")
            print msg