Programmatically exit the REPL

Matthew Fitzgibbons elessar at nienna.org
Tue Aug 26 16:18:16 EDT 2008


Almar Klein wrote:
> Hi,
> 
> If you insist on writing your own shell, you can also consider running 
> the commands in another python process.
> I took the source code of Pype as an example, which uses a wx.Process. 
> I've tried the subprocess module as well, but could not get it to work.
> 
> Almar
> 
> 2008/8/26 Matthew Fitzgibbons <elessar at nienna.org 
> <mailto:elessar at nienna.org>>
> 
>     Alexander Schmolck wrote:
> 
>         Without reading your post properly or having tried to do the
>         same thing
>         myself: I think you might want to have a look at ipython; it
>         gives a better
>         REPL and "embedding ipython" should give you plenty of hits as well.
> 
> 
>     Thanks for the tip; I hadn't heard of ipython before. I will
>     certainly check it out. However, if anyone knows how to break out of
>     the interactive interpreter from another thread, I'd still very much
>     like to hear about it. :)
> 
> 
>     -Matt
>     --
>     http://mail.python.org/mailman/listinfo/python-list
> 
> 

The whole point is that I *don't* want to write my own shell, I want to 
use the Python interactive shell (iPython, while very neat, is overkill 
for this purpose, and an extra dependency).

I use subprocess regularly, but it doesn't work in this case because (a) 
the point of using an interactive interpreter is so that I can interact 
with the job *while it's running* and (b) I *still* wouldn't be able 
exit the interactive shell cleanly (I'd have to look up the PID and kill 
it via the shell -- very ugly and not portable).

-Matt



More information about the Python-list mailing list