The PDB is a Python-brought package that provides an interactive source code debugging feature for Python programs, including setting breakpoints, stepping through debugging, entering function debugging, viewing current code, viewing stack fragments, dynamically changing the values of variables, and more. The PDB provides some common debugging commands
thead>
| command |
explanation |
| break or B set breakpoint |
set breakpoint |
| continue or C | td> continue executing program
| list or L |
View Code snippet for current line |
| step or S |
enter function |
| return or R |
executes the code until it returns from the current function |
| exit or Q |
abort and exit |
| next or n |
execute next line |
| pp |
Print variable value |
| help |
help |
The following is a typical Python debugging process:
1 Import PDB 2 pdb.set_trace () 3 " AAA " 4 " BBB " 5 " CCC " 6 Final = a + B +7 Print final
Debugging Python scripts with PDB