Migrating Ipython namespace to ipdb

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

How to set breakpoint in foo.bar and run foo.bar(x) in the debugger?

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

+4
source share
1 answer

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

 import pdb pdb.runcall(foo.bar, x) 
+5
source

Source: https://habr.com/ru/post/1347710/


All Articles