It was a little talked about at a study session, so I looked it up.
Just before the line you want to debug, add:
from IPython.core.debugger import Pdb; Pdb().set_trace()
You can use the
Trace
of ʻIPython.core.debugger`, but it is now treated as DEPRECATED. Reference: IPython issue # 9940
If you execute it normally with Jupyter or iPython Notebook, the execution will be interrupted immediately after the line added in the previous section.
Enter the command in the text field that appears after ʻipdb> . Help is displayed with
h. It ends with
q`.
Reference: Python Ipdb Cheatsheet
command | Description |
---|---|
n | Run until next line(next) |
c | Continue execution until next breakpoint(continue) |
unt line number | Execute until the specified line is reached(until) |
d | Step in(down) |
u | Step out(up) |
s | Execute until the next function call(step) |
r | Run until the current function returns(return) |
q | Run to the end and finish(quit) |
command | Description |
---|---|
p variable name | Show variable value(print) |
a | Show the arguments of the current function(args) |
w | Show stack trace(where) |
h | help(help) |
command | Description |
---|---|
b Line number or function name | Set breakpoints(break) |
tbreak line number or function name | Set a temporary breakpoint(Deleted when a breakpoint is reached) |
disable number | Disable breakpoints |
enable number | Enable breakpoints |
ignore number count | Ignore breakpoints a specified number of times |
condition number Condition to set | Change the judgment value of the condition at the breakpoint |
cl | Remove all breakpoints(clear) |
Recommended Posts