can i use python -m pdb for specific line?

the command:

python -m pdb example.py

will stop at the top of example.py file.

if want to stop at line 10, how can i do? can i achieve this by just add some other arguments?

what i can figure out is to use “b 10” after running above command.

That’s correct, once you are in the debugger you can set a breakpoint at line 10 and then type ‘c’ to continue execution; execution will stop at the breakpoint.

Another option if you are using Python 3.7 or later is to add breakpoint() as a line in your source code at the point where you want to enter the debugger, and then run your program normally (not using pdb). The debugger will be opened at that point when the interpreter reaches the breakpoint in the source code.

2 Likes