I often use print () for debugging programs, but it seems that it can be done more efficiently by using pdb, so note
Write the following command at the point you want to debug.
import pdb; pdb.set_trace()
This is OK. If you run the program after inserting this, the process will stop at the insertion part. You can also step in using the following commands.
| command | table |
|---|---|
| s (step) | Step in |
| n (next) | Step over |
| r (return) | Step out |
| l (list) | View source code for the current line |
| a (args) | Show the arguments of the current function |
| p | |
| c (cont(inue)) | Run to the next breakpoint |
By the way, even if you do not insert it in the program, when you execute the script,
$ python -m pdb <Script name>
But it can be used. (Thanks to @shiracamus.)
Recommended Posts