Search code examples
pythondebuggingtrace

trace python: only include some files


I know that I can use this to trace the command execution:

python -m trace -t script.py

But I want to reduce the output: Only files which are in my src/ (pip install -e ...) should be shown.

How can I do this?


Solution

  • My solution is based on the answer of Brian Cain:

    export PYTHONIOENCODING=utf-8
    python -m trace --ignore-dir=$HOME/lib64:$HOME/lib:/usr -t script.py
    

    My virtualenv is directly in $HOME and my code is installed editable in $HOME/src.

    This PYTHONIOENCODING=utf-8; is needed since I got UnicodeErrors if there where non ascii characters in the python code.