You can use the b
command, followed by the module name and line number, to set a breakpoint:
$ b util:5
This will set a breakpoint on line 5 of the util
module. If we supply no module name, then pdb
will set a breakpoint in the current module we’re running.
Running b
with no line number will display a list of all our current breakpoints, which we can toggle on and off or clear. The c
command will continue execution up until the next breakpoint is hit. a
will show us the arguments passed into a function.
We can also create conditional breakpoints, which are breakpoints that only hit when a certain condition is met. In this example, you create a breakpoint that only hits if the argument passed to get_path()
does not start with a /
:
$ b util.get_path, not filename.startswith('/')
When you’re setting the breakpoint with a function name rather than a line number, note that the expression should use only function arguments or global variables that are available at the time the function is entered. Otherwise, the breakpoint will stop execution in the function regardless of the expression’s value.
Amitoz on March 16, 2020
Hello, Is there any way to download the files? example[1-5].py ?