I assume there is something similar in one of the debugger modules.
I *THINK* you want to skip the first 2, not the last two, is that
correct ? ( or was it the other way around? )
- Steve Majewski (804-982-0831) <sdm7g@Virginia.EDU>
- UVA Department of Molecular Physiology and Biological Physics
def trace():
from sys import last_traceback,last_type,last_value
from linecache import getline
tb = last_traceback
print 'Traceback (innermost last):'
while tb:
fname = tb.tb_frame.f_code.co_filename
line = getline( fname, tb.tb_lineno )
print ' File "'+fname+'", line', tb.tb_lineno
if line[:-1] : print ' ',line[:-1]
tb = tb.tb_next
print last_type+':', last_value
return last_traceback
#
# some test functions:
# try err(), then errt() and compare.
#
def f(a,b):
print f, (a,b)
return g(a,b)
def g(a,b):
print g, (a,b)
return f(a)
def err():
print err
return f(1,2)
def errt():
print errt
try:
return f(1,2)
except:
return trace()