Manually printing traceback?

Andrei Kulakov sill at optonline.net
Tue Aug 7 22:30:00 EDT 2001


Hello,

If I run this code: l = []; print l[1], I get a traceback.
If I change it to:

import sys
l = []
try: print l[1]
except:
    print sys.exc_info()

I get a tuple, 3rd element of which is the traceback object. How do i print
it? I tried doing print sys.exc_info()[2]() but that doesn't work. I also
read libref and langref and i couldn't find anything enlightening on this.
I found a post where paul prescott asks a similar question and gvr tells him
that you basically have to read code for some debugger, or something of this
sort.. that's over my head, i'm afraid.

The reason i ask is that my program (cymbaline) doesn't print out exceptions
that it raises. I have no idea why.. I don't have any big chunks in try:
except: catch-all blocks.. So, alternatively, if i knew what else could be
causing this, i wouldn't need the answer the my first question. I just need
the answer to either one :P

Thanks,

 - Andrei



-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: http://silmarill.org/cymbaline



More information about the Python-list mailing list