Skip to content

Latest commit

 

History

History
49 lines (34 loc) · 1.02 KB

File metadata and controls

49 lines (34 loc) · 1.02 KB

python debugger

debug a python standalone script

python -m pdb myscript.py

debug a python module

python -m pdb -m mymodule.cli

debug within the python src code

import pdb

def make_bread():
    pdb.set_trace()
    return "I don't have time"

print(make_bread())

if you are using Python 3.7+ then you can simply use the breakpoint() built-in function. It automatically imports pdb and calls pdb.set_trace().

Within pdb

? will show command reference, here's list of common commands

(Pdb) ?c
c(ont(inue))
        Continue execution, only stop when a breakpoint is encountered.

(Pdb) ?w
w(here)
        Print a stack trace, with the most recent frame at the bottom.
        An arrow indicates the "current frame", which determines the
        context of most commands.  'bt' is an alias for this command.

if needs more detailed description

"help pdb" shows the full pdb documentation