trace — 跟踪或追踪 Python 语句的执行

源代码: Lib/trace.py


The trace module allows you to trace program execution, generate annotated statement coverage listings, print caller/callee relationships and list functions executed during a program run. It can be used in another program or from the command line.

另请参阅

Coverage.py

A popular third-party coverage tool that provides HTML output along with advanced features such as branch coverage.

命令行用法

The trace module can be invoked from the command line. It can be as simple as

python -m trace --count -C . somefile.py ...