[IPython-user] exiting ipshell()

Fernando Perez fperez.net at gmail.com
Tue Oct 3 13:59:50 CDT 2006


On 10/3/06, Kumar Golap <tizan.moris at gmail.com> wrote:
> Hi Fernando,
>
> I'm launching the fork in a script launched from within the
> ipshell()...so basically i want to do what you propose from withing
> the ipython shell...
>
> The snippet of code below is part of a python function that a user
> will be running inside ipython.

Well, the ipshell instance sees its surrounding namespace, so you can
do this in the ipython embedded instance (I'm assuming the call was
made as 'ipshell()', change accordingly):

In [1]: ipshell.set_dummy_mode(1)

and it won't get called again unless something in the enclosing
program sets the dummy mode back to false.  If this is a very common
need for you, you can easily expose a global which wraps this
operation in a shorter call and which hides the name ipshell (which is
an implementation detail) from your users, so they always know they
just need to call

nointeract()

or somesuch in your programs, and the nointeract() function would be:

def nointeract():
  name_of_your_ipshell.set_dummy_mode(False)


If I've misunderstood your needs let me know.

Cheers,

f


More information about the IPython-user mailing list