Here’s how to debug python script using pdb in terminal ( command line). It’s an useful presentation to know how to use pdb
Here you can set and clear the breakpoints. And, you can set values to variables. Keep handy the listed commands. Here is How to avoid syntax errors in python.
To start debugging, you need a ‘pdb’ package in Python.
See me example Python script – sample.py. Here, you’re importing pdb and debugging.
$python -m pdb sample.py
How to use ‘pdb’ in Command Line to Debug Python Script
Python ‘pdb’ Debugging Commands.
1. Command to List source code:
l – it displays 11 lines of source code
ll – it display entire source codes
2. Command to Set break point:
b 10 – it sets break point at line 10.
3. Command to Continue:
c – it continues execution.
4. Command to debug line by line:
s – just executes one line.
5. Command to Execute next line.
n – it executes next line.
6. Command to Execute up level:
u 10 – execution up 10 lines.
7. Command to Execute down level:
d 10 – execution down 10 lines.
9. Command to 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.