29

What do you insert into Python source code to have it break into pdb (when execution gets to that spot)?

Martijn Pieters
  • 963,270
  • 265
  • 3,804
  • 3,187
Daryl Spitzer
  • 133,599
  • 75
  • 153
  • 171

2 Answers2

41
import pdb; pdb.set_trace()

See Python: Coding in the Debugger for Beginners for this and more helpful hints.

Daryl Spitzer
  • 133,599
  • 75
  • 153
  • 171
11

As of Python 3.7, you can use breakpoint() - https://docs.python.org/3/library/functions.html#breakpoint

Adam Baxter
  • 1,677
  • 20
  • 39