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

10,883

Solution 1

import pdb; pdb.set_trace()

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

Solution 2

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

Share:
10,883
Daryl Spitzer
Author by

Daryl Spitzer

Father of three, husband, computer programmer (Pythonista), skeptic, atheist, podcast listener, baseball fan, Canadian (in the United States).

Updated on June 17, 2022

Comments

  • Daryl Spitzer
    Daryl Spitzer about 2 years

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