Here is a topic to use the pdb utility for debugging the python program. Below, you’ll find set and clear the breakpoints set values to variables. A handy list of commands helpful for projects.
You May Also Like: How to avoid syntax errors in python
Step-1: Import pdb package
See me example Python script – sample.py. Here, you’re importing pdb and debugging.
$python -m pdb sample.py
Step-2: How to use pdb commands at Command-line
Below is the video that shows the usage of pdb commands at the command-line.
Handy list: pdb 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.
References
12 Python Interview Questions
These questions useful for your next interview and to use in your project.
Related Posts