How to debug a Python module run with python -m from the command line?

后端 未结 6 553
后悔当初
后悔当初 2020-12-09 15:20

I know that a Python script can be debugged from the command line with

python -m pdb my_script.py

if my_script.py is a script

6条回答
  •  余生分开走
    2020-12-09 15:54

    Python 3.7 adds that feature

    From the docs, it looks that your command:

    python -m pdb -m my_module
    

    will start working on Python 3.7:

    New in version 3.7: pdb.py now accepts a -m option that execute modules similar to the way python3 -m does. As with a script, the debugger will pause execution just before the first line of the module.

提交回复
热议问题