Launch Python debugger while simultaneously executing module as script

前端 未结 5 1437
你的背包
你的背包 2020-12-14 09:21

When developing a Python package, it\'s very convenient to use the -m option to run modules inside the package as scripts for quick testing. For example, for

5条回答
  •  无人及你
    2020-12-14 09:33

    There are efforts underway to solve this in Python itself. Looks like with Python 3.7, you can do:

    python -m pdb -m somepackage.somemodule
    

    And I've provided a backport for older Python versions (2.7+):

    pip install backports.pdb
    python -m backports.pdb -m somepackage.somemodule
    

提交回复
热议问题