So, IPython rocks. But what if you want to use it deep inside a program to do a bit of exploratory programming with access to the full program state etc.? Just stick these two lines of code into the place you want to start off from:
from IPython.Shell import IPShellEmbed
IPShellEmbed([])()
More info on IPShellEmbed here.
I just discovered this, and it is unbelievably useful in some situations!
Comments §
Although I should mention I use a different flavor of the same idea. I first drop to pdb and then invoke ipython from there. That way when I quit out of ipython, i can go back and forth and maybe go into ipython again.
the way I do is.
import pdb;pdb.set_trace() > this goes inside the program
and inside pdb prompt
(pdb) invoke ipython
There is no such command in pdb as 'invoke'. Can you correct this? I find this technique very interesting.
import ipdb; ipdb.set_trace()
Sorry if confused you folks. When I said 'invoke ipython' I meant invoke ipython in the way mentioned in the article.
I'm not sure if I'll ever use print to debug again