4

I am in the middle of an ipython session. I've loaded a module foo which contains a function foo.bar. While working, I notice that foo.bar gives some weird output when I feed it some input x, where x is a variable in my local ipython scope. I would like to investigate the behavior in a debugger.

How would I set a breakpoint at foo.bar and run foo.bar(x) in a debugger?

I know about pdb.set_trace(), but it would require me to open up the code of the foo module to insert a breakpoint manually, save it, reload the module in ipython, etc. There has to be a better way.

1 Answer 1

5

I believe you can use pdb.runcall in this case:

import pdb
pdb.runcall(foo.bar, x)

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.