{
    "mode": "pydoc",
    "parameter": "trace",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/trace/json",
    "generated": "2026-06-02T15:49:31Z",
    "sections": {
        "NAME": {
            "content": "trace - program/module to trace Python program or function execution\n",
            "subsections": []
        },
        "MODULE REFERENCE": {
            "content": "https://docs.python.org/3.10/library/trace.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Sample use, command line:\ntrace.py -c -f counts --ignore-dir '$prefix' spam.py eggs\ntrace.py -t --ignore-dir '$prefix' spam.py eggs\ntrace.py --trackcalls spam.py eggs\n\nSample use, programmatically\nimport sys\n\n# create a Trace object, telling it what to ignore, and whether to\n# do tracing or line-counting or both.\ntracer = trace.Trace(ignoredirs=[sys.baseprefix, sys.baseexecprefix,],\ntrace=0, count=1)\n# run the new command using the given tracer\ntracer.run('main()')\n# make a report, placing output in /tmp\nr = tracer.results()\nr.writeresults(showmissing=True, coverdir=\"/tmp\")\n",
            "subsections": []
        },
        "CLASSES": {
            "content": "builtins.object\nCoverageResults\nTrace\n",
            "subsections": [
                {
                    "name": "class CoverageResults",
                    "content": "|  CoverageResults(counts=None, calledfuncs=None, infile=None, callers=None, outfile=None)\n|\n|  Methods defined here:\n|\n|  init(self, counts=None, calledfuncs=None, infile=None, callers=None, outfile=None)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  isignoredfilename(self, filename)\n|      Return True if the filename does not refer to a file\n|      we want to have reported.\n|\n|  update(self, other)\n|      Merge in the data from another CoverageResults\n|\n|  writeresults(self, showmissing=True, summary=False, coverdir=None)\n|      Write the coverage results.\n|\n|      :param showmissing: Show lines that had no hits.\n|      :param summary: Include coverage summary per module.\n|      :param coverdir: If None, the results of each module are placed in its\n|                       directory, otherwise it is included in the directory\n|                       specified.\n|\n|  writeresultsfile(self, path, lines, lnotab, lineshit, encoding=None)\n|      Return a coverage results file in path.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class Trace",
                    "content": "|  Trace(count=1, trace=1, countfuncs=0, countcallers=0, ignoremods=(), ignoredirs=(), infile=None, outfile=None, timing=False)\n|\n|  Methods defined here:\n|\n|  init(self, count=1, trace=1, countfuncs=0, countcallers=0, ignoremods=(), ignoredirs=(), infile=None, outfile=None, timing=False)\n|      @param count true iff it should count number of times each\n|                   line is executed\n|      @param trace true iff it should print out each line that is\n|                   being counted\n|      @param countfuncs true iff it should just output a list of\n|                   (filename, modulename, funcname,) for functions\n|                   that were called at least once;  This overrides\n|                   `count' and `trace'\n|      @param ignoremods a list of the names of modules to ignore\n|      @param ignoredirs a list of the names of directories to ignore\n|                   all of the (recursive) contents of\n|      @param infile file from which to read stored counts to be\n|                   added into the results\n|      @param outfile file in which to write the results\n|      @param timing true iff timing information be displayed\n|\n|  filemodulefunctionof(self, frame)\n|\n|  globaltracecountfuncs(self, frame, why, arg)\n|      Handler for call events.\n|\n|      Adds (filename, modulename, funcname) to the self.calledfuncs dict.\n|\n|  globaltracelt(self, frame, why, arg)\n|      Handler for call events.\n|\n|      If the code block being entered is to be ignored, returns `None',\n|      else returns self.localtrace.\n|\n|  globaltracetrackcallers(self, frame, why, arg)\n|      Handler for call events.\n|\n|      Adds information about who called who to the self.callers dict.\n|\n|  localtracecount(self, frame, why, arg)\n|\n|  localtracetrace(self, frame, why, arg)\n|\n|  localtracetraceandcount(self, frame, why, arg)\n|\n|  results(self)\n|\n|  run(self, cmd)\n|\n|  runctx(self, cmd, globals=None, locals=None)\n|\n|  runfunc(self, func, /, *args, kw)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                }
            ]
        },
        "DATA": {
            "content": "all = ['Trace', 'CoverageResults']\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3.10/trace.py\n\n",
            "subsections": []
        }
    },
    "summary": "trace - program/module to trace Python program or function execution",
    "flags": [],
    "examples": [],
    "see_also": []
}