Here is python ‘pdb’ debugging utility for python programs. Here is pdb tutorial on how to debug .py module at command level interface (CLI).
Here is how to set break point and how to clear them. Also, in the below, I have listed useful pdb commands.
You May Also like: How to avoid syntax errors in python.
ON THIS PAGE
- Install ‘pdb’ package in your Python interpreter
- The usage of ‘pdb’ explained in Video
- Top pdb commands
1. Install ‘pdb’ package.
My python script is sample.py. Here, you are importing pdb and executing the debug.
$python import pdb
$python -m pdb sample.py
2. How to use ‘pdb’ utility.
3. Python pdb commands to debug
List source code:
l – it displays 11 lines of source code
ll – it display entire source codes
b 10 – it sets break point at line 10.
c – it continues execution.
Debug line by line:
s – just executes one line.
Execute next line.
n – it executes next line.
Execute up level:
u 10 – execution up 10 lines.
Execute down level:
d 10 – execution down 10 lines.
Quit from debugger:
q – to quit from debugger.
12 Python Top Interview Questions
These questions useful for your next interview and to use in your project.