Restart the interactive python shell like in IDLE

Ricardo Abreu gumbeto at gmail.com
Mon Sep 30 12:45:07 EDT 2013


On Thursday, June 11, 2009 1:48:42 AM UTC+2, Chris Rebert wrote:
> On Wed, Jun 10, 2009 at 12:01 PM, Matt Burson<msburson at gmail.com> wrote:
> > Is there a way to reproduce the behavior of IDLE's restart shell ability by
> > using a function? I thought there would be since you can exit python by
> > executing the simple quit() function I thought there would be an equally
> > simple function name something like restart(). I'd prefer something like
> > this as opposed to having to exit the shell and then start it up again to
> > refresh it.
> 
> I believe IDLE itself implements the "restart" capability by killing
> and re-launching its Python interpreter subprocess, so it's not like
> it's using some hidden capability of Python to accomplish this.
> Is doing Ctrl+D, up-arrow, Enter really that hard? It's even fewer
> keystrokes than "restart()"...
> 
> Cheers,
> Chris
> -- 
> http://blog.rebertia.com

You might be launching python from something else other than a shell and it might be harder to re-launch it from there



More information about the Python-list mailing list