31

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

2 Answers 2

44
import pdb; pdb.set_trace()

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

Sign up to request clarification or add additional context in comments.

2 Comments

From the FAQ: > It's also perfectly fine to ask and answer your own programming question, but pretend you're on Jeopardy: phrase it in the form of a question.
How would that work in an IDE? It doesn't work in Pycharm
18

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.