ipdb
ipdb copied to clipboard
access to magic functions?
Magic functions don't seem to work from the ipdb prompt, although they are visible in the tab completion.
ipdb> %prun some_function()
*** SyntaxError: invalid syntax (<stdin>, line 1)
I do not use IPython enough to guess what could cause this syntax error. Any fix welcome though.
Well, it's nothing related to ipdb, but an IPython issue.
In latest IPython version (0.13.1 or git trunk), some magic function pdef/pdoc/pinfo have already been exposed to IPython debugger interface.
I tried to expose "prun" in IPython according to the following thread, but it is not as easy to handle as other pdef/pdoc/pinfo commands. Still got no luck yet. http://mail.scipy.org/pipermail/ipython-user/2013-January/011965.html
I'll close this issue then.
If anyone comes with a fix, feel free to open a new issue referring this one.
Has no one been able to implement this? :( Makes me quite sad that I can't pprint by default in ipdb.
http://stackoverflow.com/questions/16184487/use-ipython-magic-functions-in-ipdb-shell
We can make a hook and dispatch input that startswith %
to ipython magics as @gotcha 's link suggests.
However this is not ideal - e.g. %cpaste
is actually pasting into IPython's shell instead of ipdb session...
@k-funk are there any particular magics that you would like to use?
See: https://github.com/gotcha/ipdb/compare/master...disconnect3d:ipdb_add_magic_research?expand=1
Being able to pretty print is the most important for me, but there are quite a few useful magics that I would use: timeit, pwd, env
Hi, %who
and %whos
don't work in ipdb :
ipdb> %who
*** SyntaxError: invalid syntax
ipdb> %whos
*** SyntaxError: invalid syntax
Is this because of ipython ?
Is there an ipython issue about this ?
This feature would add a lot of value to ipdb. Anyone up to champion this feature?
This would have to be done on IPython side, in IPython.terminal.debugger.TerminalPdb.cmdloop
. I'm looking into it, but no promisses.
Another issue with this is that the context of the debugger ≠ context magics operate in. Working around this isn't hard, but there are probably few other things like this that would have to be taken care of.
FYI IPython on master
now runs its own interactive shell on interact
, so technically you can just use that to get to the shell and run any given magic command there.
Not every magic makes sense in context of Ipdb - e.g. what would %autocall
mean? There's a lot of backend that goes into magics that Ipdb's cmd.Cmd
just does not posses, and trying to marry the two seems to result in an unending stream of spaghetti code.
Now that I think of it, it seems to me that some magics could be just ported on a case-by-case basis into Ipdb as debugger commands. It might get simpler if a way of adding "plugin" commands was introduced to Ipdb. That way it would be the case of wrapping magics selectively so that they cooperate with that system.
@MrMino Yes. It would be great porting %who
and %whos
for ipdb
.