gotcha / ipdb

Integration of IPython pdb
BSD 3-Clause "New" or "Revised" License
1.85k stars 146 forks source link

access to magic functions? #33

Open adamgreenhall opened 11 years ago

adamgreenhall commented 11 years ago

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)
gotcha commented 11 years ago

I do not use IPython enough to guess what could cause this syntax error. Any fix welcome though.

unicell commented 11 years ago

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

gotcha commented 11 years ago

I'll close this issue then.

If anyone comes with a fix, feel free to open a new issue referring this one.

k-funk commented 10 years ago

Has no one been able to implement this? :( Makes me quite sad that I can't pprint by default in ipdb.

gotcha commented 9 years ago

http://stackoverflow.com/questions/16184487/use-ipython-magic-functions-in-ipdb-shell

disconnect3d commented 7 years ago

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

k-funk commented 7 years ago

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

sebma commented 7 years ago

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 ?

AdrienLemaire commented 5 years ago

This feature would add a lot of value to ipdb. Anyone up to champion this feature?

MrMino commented 3 years ago

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.

MrMino commented 3 years ago

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.

sebma commented 3 years ago

@MrMino Yes. It would be great porting %who and %whos for ipdb.