[IPython-dev] exit() in a Spyder script
Carlos Córdoba
ccordoba12 at gmail.com
Mon Sep 22 01:08:55 EDT 2014
Hi,
We (the Spyder team) didn't want to wash our hands and transfer the
problem to the IPython one :-) The thing is if you're calling exit(),
you want the Python interpreter to terminate, and Spyder can't control this.
However, I found an easy solution, following your suggestion about ask_exit:
1. Define a pass function like this:
def f(): pass
2. Run this code in the IPython console:
In [1]: ip = get_ipython()
In [2]: ip.ask_exit = f
Then exit() won't have any effect.
If you want this code to always evaluate for any IPython Console in
Spyder, you need to go to:
Preferences > IPython Console > Startup > Run code
and paste this line in the "Lines" text field:
def f(): pass, get_ipython().ask_exit = f
Cheers,
Carlos
El 21/09/14 a las #4, Robert Pollak escribió:
> [2nd try - it seems this didn't get posted because I was not subscribed.]
>
> Hello,
>
> I am using the Spyder IDE [1] within WinPython [2]. Spyder runs scripts
> within IPython. When I take a script containing exit(), and run it
> within Spyder, this command kills the Python kernel:
>
> """
> It seems the kernel died unexpectedly. Use 'Restart kernel' to continue
> using this console.
> """
>
> I have reported this to Spyder as issue 1974 [3], but I was told that
>> [...] the exception should be caught inside IPython itself.
> Is this true?
> In the IPython documentation I have read about an ask_exit() callback.
> Should Spyder register this callback to catch the exit()?
>
> Best regards,
> Robert
>
>
> [1] https://code.google.com/p/spyderlib/
> [2] http://winpython.sourceforge.net/
> [3] https://code.google.com/p/spyderlib/issues/detail?id=1974
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140922/b828091e/attachment.html>
More information about the IPython-dev
mailing list