Daryl Spitzer
Daryl Spitzer

Reputation: 149594

How do you break into the debugger from Python source code?

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

Upvotes: 31

Views: 13525

Answers (2)

Adam
Adam

Reputation: 2097

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

Upvotes: 18

Daryl Spitzer
Daryl Spitzer

Reputation: 149594

import pdb; pdb.set_trace()

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

Upvotes: 44

Related Questions