Simpler way to put PDB breakpoints in Python code?

后端 未结 14 2205
不知归路
不知归路 2020-11-30 18:21

Just a convenience question. I\'ve been a bit spoiled with debuggers in IDEs like Visual Studio and XCode. I find it a bit clumsy to have to type import pdb; pdb.set_t

14条回答
  •  無奈伤痛
    2020-11-30 18:59

    You can run your program into pdb from the command line by running

    python -m pdb your_script.py

    It will break on the 1st line, then you'll be able to add a breakpoint wherever you want in your code using the break command, its syntax is:

    b(reak) [[filename:]lineno | function[, condition]]

    It is flexible enough to give you the ability to add a breakpoint anywhere.

提交回复
热议问题