Python tracer
From Noah.org
Download tracer.py
"""This traces python code. Add a settrace call somewhere in your program: if __name__ == '__main__': sys.settrace(tracer) main() $Id: tracer.py 234 2008-04-07 21:30:18Z noah $ """ import sys, os, linecache def tracer(frame, event, arg): if event == "line": lineno = frame.f_lineno filename = frame.f_globals["__file__"] if filename[-1] != 'y': # convert .pyc and .pyo files to .py filename = filename[:-1] line = linecache.getline(filename, lineno).rstrip().replace('\t',' ') print "%s : %04s : %s" % (os.path.basename(filename), lineno, line) return tracer