Skip to content
← Back to Community
set breakpoint pyton 3.6
Profile icon
r1200gs

How do i set a breakpoint in the debugger? (Python 3.6)

Voters
Profile icon
dmsvko1
Profile icon
fatimaalkaabi4
Profile icon
BrandonWhite10
Profile icon
PEEMAIKEELAKITP
Profile icon
DANIELADONASCIM
Profile icon
MihirMahajani
Profile icon
heyitsmarcus
Profile icon
r1200gs
Comments
hotnewtop
Profile icon
heyitsmarcus

Hey @r1200gs,

You can easily do that with the pdb package. Just use import pdb at the start of the script, and then run pdb.set_trace() wherever you'd like a breakpoint to be set. What will happen is that when you run the code, all of it will execute up until the breakpoint and then an interactive shell will appear where you can do more Python coding to see what will appear!

I made a simple repl for you to show off setting a breakpoint:
https://repl.it/@heyitsmarcus/test-python-debug

I hope this helps!

If this solves your problem, please consider upvoting and marking my answer as the accepted answer to close this question. If you have any more questions, I'll continue to answer them to the best of my ability.

Profile icon
heyitsmarcus

@heyitsmarcus Oh and here are a few commands you can use with pdb:

  • c continue execution
  • n step to the next line within the same function
  • s step to the next line in this function or a called function
  • q quit the debugger/execution