25.10.1 Command Line Usage

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

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

The above will generate annotated listings of all Python modules imported during the execution of somefile.py.

The following command-line arguments are supported:

--trace, -t
Display lines as they are executed.

--count, -c
Produce a set of annotated listing files upon program completion that shows how many times each statement was executed.

--report, -r
Produce an annotated list from an earlier program run that used the --count and --file arguments.

--no-report, -R
Do not generate annotated listings. This is useful if you intend to make several runs with --count then produce a single set of annotated listings at the end.

--listfuncs, -l
List the functions executed by running the program.

--trackcalls, -T
Generate calling relationships exposed by running the program.

--file, -f
Name a file containing (or to contain) counts.

--coverdir, -C
Name a directory in which to save annotated listing files.

--missing, -m
When generating annotated listings, mark lines which were not executed with `>>>>>>'.

--summary, -s
When using --count or --report, write a brief summary to stdout for each file processed.

--ignore-module
Ignore the named module and its submodules (if it is a package). May be given multiple times.

--ignore-dir
Ignore all modules and packages in the named directory and subdirectories. May be given multiple times.

See About this document... for information on suggesting changes.