Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)?

like image 771
Daryl Spitzer Avatar asked Sep 29 '08 19:09

Daryl Spitzer


2 Answers

import pdb; pdb.set_trace() 

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

like image 164
Daryl Spitzer Avatar answered Oct 04 '22 16:10

Daryl Spitzer


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

like image 24
Adam Baxter Avatar answered Oct 04 '22 16:10

Adam Baxter