29

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

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Daryl Spitzer
  • 143,156
  • 76
  • 154
  • 173

2 Answers2

42
import pdb; pdb.set_trace()

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

Daryl Spitzer
  • 143,156
  • 76
  • 154
  • 173
14

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

Adam Baxter
  • 1,907
  • 21
  • 41