Transfer Ipython namespace to ipdb
Question: 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.


Answer: I believe you can use
[`pdb.runcall`](http://docs.python.org/library/pdb.html#pdb.runcall) in this
case:

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

