开发者

Transfer Ipython namespace to ipdb

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开发者_JAVA技巧 has to be a better way.


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

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜