[IPython-dev] exit magic vs exit function(s?) for qtconsole
Fernando Perez
fperez.net at gmail.com
Thu Oct 21 20:01:56 EDT 2010
On Wed, Oct 20, 2010 at 1:42 AM, Erik Tollerud <erik.tollerud at gmail.com> wrote:
>
>
> The trouble is, if I do either "exit" or "exit()" at the console, it
> goes to the exit *function* instead of the exit magic command. In
> fact, "exit()" and "exit" seem to follow very different code paths
> (one is the IPython.core.quitter.Quitter class, and I'm not sure where
> the other one gets hooked in). Is there a particular reason why there
> are three different versions of "exit"? And if not, is there a
> straightforward way to get the exit magic to by default override the
> other two and use only the magic command in the qtconsole?
Not really, other than historical madness :) Well, that and the fact
that exit/quit are actually injected into the builtin namespace by
python itself:
>>> import __builtin__ as b
>>> b.exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>> b.quit
Use quit() or Ctrl-D (i.e. EOF) to exit
As far as I'm concerned, this stuff is fair game for a cleanup. In
the past I used to be overly sensitive to not doing *anything* that
differed in any way from the default python shell, but honestly the
above behavior is just nonsense, and we should do better without being
afraid.
My proposal:
- remove exit/quit from the builtin namespace
- stop adding our own exit/quit functions
- just have a single magic (aliased to exit/quit names) that does
unconditional exit just by being called, bonus points for having the
exit control options available in it as you suggested.
Unless someone disagrees with this approach, whip up the code and send
a pull request when ready!
Cheers,
f
More information about the IPython-dev
mailing list