[IPython-User] Invoking ipython shell in the middle of script run and using magic commands

Joon Ro joonpyro@gmail....
Sun Apr 8 14:03:52 CDT 2012


Hi,

Basically what I want to do is stop the script during its run and invoke  
ipython shell,
just like setting from ipdb import set_trace; set_trace().

But also I want to use some magic commands, especially %timeit, in the  
shell, so I can
check how a couple of different implementation of a function performs. I  
want to do it
in the middle of a script run because there is a lot of overhead and I  
don't want to
make another script just for the testing.

I found putting the following into the code pretty much did what I want:

 from IPython import embed
embed()

as this gives all the variables with their values and also I could use  
magic commands as well.
I wonder if there is better way to do this or this is the right way?

Thank you,
Joon


More information about the IPython-User mailing list