This was not very obvious, but I found that if I use the parameter countfuncsin traceor the parameter --listfuncs, if I use tracethe command line, I get the full path names. Thus, for the program:
import trace
from recurse import recurse
tracer = trace.Trace(count=False, trace=True, countfuncs=True)
tracer.run('recurse(2)')
tracer.results().write_results()
... (using the example of Doug Hellman from here ) I get the following output:
functions called:
filename: <string>, modulename: <string>, funcname: <module>
filename: C:\Python33\lib\encodings\cp850.py, modulename: cp850, funcname: IncrementalEncoder.encode
filename: C:\Python33\lib\trace.py, modulename: trace, funcname: _unsettrace
filename: C:\usr\sjl\dev\test\python\recurse.py, modulename: recurse, funcname: recurse
This is not exactly what you were looking for, because you can see that it ignores the instruction for tracking lines of code, so it does not give the file path next to these lines of code. However, it will tell you exactly which files the Python script used.
source
share