Interpreter.trace

property Interpreter.trace

if set, a tracer will call this block every time a line of code is about to be executed.

Takes the path of the script and a line number. But the tracer is only installed in the file directly executed (not imported modules). This can significantly slow down execution because of the use of sys.settrace if not already debugging.