Exit autocall #357

Merged
merged 5 commits into from Apr 11, 2011

Conversation

Projects
None yet
3 participants
Owner

takluyver commented Apr 11, 2011

This adds exit as a subclass of IPyAutocall, so that exit and exit() both exit the shell without any fuss (similarly for Exit, quit and Quit).

The advantage of doing it this way is that we're not special casing it in the input handling code, and we're not doing something ugly from an object's __repr__.

The credit goes to David Warde-Farley (@dwf) for tackling this issue. Although we eventually settled upon this way of doing it, it wouldn't have been done at all without him.

Owner

fperez commented Apr 11, 2011

I see that in the qt console, exit and %exit behave differently: %exit doesn't prompt for any confirmation, and that's what exit/quit should do.

Furthermore, we should remove the magics altogether. With this implementation, we should only have exit/quit, not exit/quit/%{E,e}xit, %{Q,q}uit.

Owner

takluyver commented Apr 11, 2011

Yes. I'd removed the main magic, but it's redefined in zmqshell.

What do you want to do about the -k flag to %exit to leave the kernel running?

Owner

takluyver commented Apr 11, 2011

and do you mean you want to lose the capitalised forms of the names? So 'Quit' and 'Exit' shouldn't work?

Owner

fperez commented Apr 11, 2011

That's what I was thinking... Those were introduced long ago because of how messy this problem is, but with a cleaner solution, I'd rather simplify...

Contributor

dwf commented Apr 11, 2011

On 2011-04-10, at 21:22, takluyver reply@reply.github.com wrote:

and do you mean you want to lose the capitalised forms of the names? So 'Quit' and 'Exit' shouldn't work?

I don't much see the point of the capitalised forms, anyway.

Contributor

dwf commented Apr 11, 2011

On 2011-04-10, at 21:18, fperez reply@reply.github.com wrote:

I see that in the qt console, exit and %exit behave differently: %exit doesn't prompt for any confirmation, and that's what exit/quit should do.

Related: I noticed ^D doesn't work the same in the Qt console. How "terminal-faithful" do we want it to be? ;)

Owner

fperez commented Apr 11, 2011

Well, since it's still a separate window with lots more valuable state, I'm OK with a single keystroke not nuking it :)

Contributor

dwf commented Apr 11, 2011

On 2011-04-10, at 21:43, fperez reply@reply.github.com wrote:

Well, since it's still a separate window with lots more valuable state, I'm OK with a single keystroke not nuking it :)

^D in Terminal IPython usually prompts for confirmation, actually. So not quite a single keystroke. :)

Owner

takluyver commented Apr 11, 2011

Now it works properly in the two-process shell as well. And we've lost Quit and Exit.

Owner

fperez commented Apr 11, 2011

On Sun, Apr 10, 2011 at 6:56 PM, takluyver
reply@reply.github.com
wrote:

Now it works properly in the two-process shell as well. And we've lost Quit and Exit.

Great, I just tested it. Go ahead, push. Thanks!

takluyver merged commit 14fdb87 into ipython:master Apr 11, 2011

Owner

fperez commented Apr 11, 2011

On Sun, Apr 10, 2011 at 6:53 PM, dwf
reply@reply.github.com
wrote:

On 2011-04-10, at 21:43, fperez reply@reply.github.com wrote:

Well, since it's still a separate window with lots more valuable state, I'm OK  with a single keystroke not nuking it :)

^D in Terminal IPython usually prompts  for confirmation, actually. So not quite a single keystroke. :)

True, I forgot because I have set the config flag to ask on exit off.

This is one area where I don't mind the extra safety b/c the qt
console is a bit more like an 'app', I expect it to have much more
state around... what do you think?

Owner

takluyver commented Apr 11, 2011

Pushed with --no-ff.

Contributor

dwf commented Apr 11, 2011

On 2011-04-10, at 22:01, fperez reply@reply.github.com wrote:

This is one area where I don't mind the extra safety b/c the qt
console is a bit more like an 'app', I expect it to have much more
state around... what do you think?

I have no strong feelings on the matter, I just noticed it didn't work, and wondered about your stance on terminal fidelity as concerns all those ways where the Qt console isn't specifically trying to overcome a limitation of the terminal. Either way, I'll get used to it, I'm sure.

Owner

fperez commented Apr 11, 2011

If you find it an annoyance in practice, do open an issue for it. The implementation would need to keep C-D as delete if there's text on the line and only issue EOF if done on an empty line (like the readline-based console works).

But as long as it's configurable, I could see people wanting it. Evan's been great at refining the console as people point out little rough edges, see #356 for a good example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment