classification
Title: IDLE: Better document close and exit.
Type: behavior Stage:
Components: IDLE Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: epaine, lukasz.langa, taleinat, terry.reedy
Priority: normal Keywords: patch

Created on 2021-09-26 20:52 by terry.reedy, last changed 2021-09-29 05:36 by terry.reedy.

Pull Requests
URL Status Linked Edit
PR 28577 merged terry.reedy, 2021-09-27 05:27
PR 28600 merged miss-islington, 2021-09-28 12:06
PR 28601 merged miss-islington, 2021-09-28 12:06
Messages (9)
msg402678 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-09-26 20:52
On Windows:
>>> exit
'Use exit() or Ctrl-Z plus Return to exit'
>>> quit
'Use quit() or Ctrl-Z plus Return to exit'
>>> exit.eof
'Ctrl-Z plus Return'

On *nix, 'Ctrl-Z plus Return' is 'Ctrl-D (i.e, EOF)'
IDLE uses the latter even on Windows, and Ctrl-Z does not work.

Both exit and quit are instances of _sitebuiltins.Quitter
https://github.com/python/cpython/blob/e14d5ae5447ae28fc4828a9cee8e9007f9c30700/Lib/_sitebuiltins.py#L13-L26
class Quitter(object):
    def __init__(self, name, eof):
        self.name = name
        self.eof = eof
    def __repr__(self):
        return 'Use %s() or %s to exit' % (self.name, self.eof)
    def __call__ [not relevant here]

We just need to replace current exit/quit.eof as indicated above on startup.
msg402689 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-09-27 04:49
Tal, Paine: should be use exactly the raw REPL message or something that might be clearer to beginners, like 'Ctrl-D (end-of-file)'?
msg402693 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2021-09-27 06:24
How about "Control-D (end-of-file, a.k.a. EOF)" or even just "Control-D"?
msg402697 - (view) Author: E. Paine (epaine) * Date: 2021-09-27 09:00
> How about "Control-D (end-of-file, a.k.a. EOF)"

I doubt beginners care that it's EOF.

> or even just "Control-D"

I'd be a lot more inclined towards this.

> IDLE uses the latter [Ctrl-D] even on Windows, and Ctrl-Z does not work.

Is it worth considering changing this behaviour? IMO Ctrl-D is better for consistency between platforms, but wanted to throw the idea out there for discussion.
msg402768 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-28 12:06
New changeset e649e0658ff2af87b07d994c05ae048e16e31aae by Terry Jan Reedy in branch 'main':
bpo-45296: Fix exit/quit message on Windows (GH-28577)
https://github.com/python/cpython/commit/e649e0658ff2af87b07d994c05ae048e16e31aae
msg402773 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-28 12:35
New changeset 813fbba4cab4556e55d6044c05725a26ec20b648 by Miss Islington (bot) in branch '3.9':
bpo-45296: Fix exit/quit message on Windows (GH-28577) (GH-28601)
https://github.com/python/cpython/commit/813fbba4cab4556e55d6044c05725a26ec20b648
msg402774 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-28 12:35
New changeset acd46feff3c06d3f1d00ab850e530c519445a737 by Miss Islington (bot) in branch '3.10':
bpo-45296: Fix exit/quit message on Windows (GH-28577) (GH-28600)
https://github.com/python/cpython/commit/acd46feff3c06d3f1d00ab850e530c519445a737
msg402775 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-28 12:38
The wording chosen by Terry, i.e. "Ctrl-D (end-of-file)", is pretty clear. Merged and fixed. Thanks!
msg402820 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-09-29 05:35
Unfortunately, I have discovered, the new wording is better but only correct for IDLE when Shell is the only window.

On the file menu, I want to:
A. Change 'Close' to 'Close Window', so it is clear that 'Close'/Alt-F4 only close the window and not IDLE.
B. Also change 'Exit' to 'Exit IDLE' or maybe 'Quit IDLE', so it is clearer that this and Ctrl-Q close all windows and exit IDLE.  Ctrl-Q is the default binding for 'close-all-windows', which users can configure.

Also, add a little in the doc entry for these choices.  Or maybe open a separate issue to add the option name for all menu entry hotkeys that can be rebound.  I don't know how many that is.

For a single window app, like the REPL, when not running in Command Prompt or the equivalent, closing the window and exiting the application are the same thing.  The same is true when Shell is the only IDLE window.  Closing Shell exits IDLE.  After submitting the PR, I discovered that exit() and quit() only close Shell but do not exit IDLE if there are other windows.  So the message should really be something like the following:

To close Shell, enter 'exit()', 'quit()', or 'Alt-F4'.
To exit IDLE, hit 'Ctrl-Q', hotkey for 'File >= Exit IDLE'.

This requires replacing the __repr__ method.  Someone who rebinds either hotkey option, which I expect is rare, will have to remember that they did so if that happen to enter either 'exit' or 'quit' without parens.
--

The question of IDLE on Windows and <^Z Return> was discussed some years ago on an issue a vaguely remember but could not find.  It was decided to either not add it or maybe to remove it, and key cross-platform ^D for closing Shell (and only Shell as it does nothing in Editor).  I don't want to change that decision.
History
Date User Action Args
2021-09-29 05:36:00terry.reedysetstatus: closed -> open

title: IDLE: Change Ctrl-Z note in exit/quit repr on Windows -> IDLE: Better document close and exit.
nosy: - miss-islington

messages: + msg402820
resolution: fixed ->
stage: resolved ->
2021-09-28 12:38:37lukasz.langasetstatus: open -> closed
resolution: fixed
messages: + msg402775

stage: patch review -> resolved
2021-09-28 12:35:27lukasz.langasetmessages: + msg402774
2021-09-28 12:35:08lukasz.langasetmessages: + msg402773
2021-09-28 12:06:10miss-islingtonsetpull_requests: + pull_request26977
2021-09-28 12:06:05miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request26976
2021-09-28 12:06:05lukasz.langasetnosy: + lukasz.langa
messages: + msg402768
2021-09-27 09:00:30epainesetmessages: + msg402697
2021-09-27 06:24:16taleinatsetmessages: + msg402693
2021-09-27 05:27:08terry.reedysetkeywords: + patch
stage: patch review
pull_requests: + pull_request26960
2021-09-27 04:49:24terry.reedysetnosy: + taleinat, epaine
messages: + msg402689
2021-09-27 04:45:25terry.reedysetassignee: terry.reedy
type: behavior
components: + IDLE
versions: + Python 3.9, Python 3.10, Python 3.11
2021-09-26 20:52:27terry.reedycreate