Manually printing traceback?

Andrei Kulakov sill at
Wed Aug 8 04:30:00 CEST 2001


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]
    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


 - Andrei

Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at:

More information about the Python-list mailing list