This doc intends to provide basic understanding / skill to use the Python Debugger (PDB).
There's certainly more to the debugger than what's below. This just provides quick and dirty info.
Open a terminal / command line and navigate to the directory containing the main file you want to debug.
Run the following line.
python -m pdb some_file.py
Quick breakdown. -->
python
is for Python
-m
is a shell flag that tells Python to use whatever module that follows when running the script
pdb
is the module that Python will use when executing the script
some_file.py
is the name of the script... likely, your file will be called something different.
Now, you should be in debugger mode. What you see will depend on your some_file.py
, however it should look like the first row of that file along with a (pdb)
prompt.
Here are some quick codes to know.
n
stands for next.
s
stands for step in
until
ll
stands for long list and shows where you are in the script
pp
for pretty print the value of an expression
b
set a break point
If you finish your debugging before the script finishes, just type exit
at the prompt.