简体   繁体   中英

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 has to be a better way.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM