[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-10-07 Thread Terry J. Reedy
Terry J. Reedy added the comment: Steven's list left out the standard way of closing *any* windowed app -- click the close button on the title bar. Works on all major systems. Its does a little too much when python is started on a command line (by closing the console), but beginners, at

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-09-27 Thread Vedran Čačić
Vedran Čačić added the comment: Just wanted to say that "raise SystemExit" is shorter than "import sys; sys.exit()", has no special characters (just letters and space) and is really much quicker to write. Yes, it doesn't work if someone rebound SystemExit, but if that's your problem, you

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-09-26 Thread Steven D'Aprano
Steven D'Aprano added the comment: > That is true, but there are a couple setups where that doesn't work > (those keypresses are consumed by something else). I may not be a good > data point though. Can you give an example of a setup where Ctrl-D is consumed but "import sys ENTER

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-09-26 Thread Filipe Laíns
Filipe Laíns added the comment: > Without disagreeing with the general sentiment, just note that you can always > do Ctrl-D. That is true, but there are a couple setups where that doesn't work (those keypresses are consumed by something else). I may not be a good data point though. >

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-09-25 Thread Steven D'Aprano
Steven D'Aprano added the comment: > Typing `import sys; sys.exit()` every time I want to test something > quick on the REPL is awful UX. It truly is awful. So why do you do it that way? There are at least four other ways to cleanly exit the REPL. 1. raise SystemExit 2. exit() 3. quit()

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-09-25 Thread Eryk Sun
Eryk Sun added the comment: Running the REPL with -S is unusual, so having to use sys.exit() or `raise SystemExit` in that case shouldn't be an issue. A user who wants custom behavior for `exit` could override sys.displayhook() in the PYTHONSTARTUP file. For example: import sys

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-09-25 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > Typing `import sys; sys.exit()` every time I want to test something quick on > the REPL is awful UX. Without disagreeing with the general sentiment, just note that you can always do Ctrl-D. -- ___

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-09-25 Thread Filipe Laíns
Filipe Laíns added the comment: > In my view, that's exactly why it _shouldn't_ have a special treatment. After > all, site can add many more builtins. Do you want all of them to have > autocall? No, and I did not suggest anything of the sort. I just want the exit because of its integral

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-09-24 Thread Vedran Čačić
Vedran Čačić added the comment: > why it would be beneficial to have custom handling like this for exit is that > exit is a site-builtin, not a builtin. In my view, that's exactly why it _shouldn't_ have a special treatment. After all, site can add many more builtins. Do you want all of them

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-09-24 Thread Filipe Laíns
Filipe Laíns added the comment: One technical argument on why it would be beneficial to have custom handling like this for exit is that exit is a site-builtin, not a builtin. $ python -S Python 3.9.7 (default, Aug 31 2021, 13:28:12) [GCC 11.1.0] on linux >>> exit() Traceback (most recent call

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-08-23 Thread Diego Ramirez
Change by Diego Ramirez : -- nosy: +DiddiLeija ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-08-20 Thread Mark Dickinson
Change by Mark Dickinson : -- nosy: -mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-16 Thread Terry J. Reedy
Terry J. Reedy added the comment: Another issue: exit() and quit() work unconditionally when called, regardless of the context: "a = (3, exit(), 'abc')". The abbreviated versions will not. An alternative change is to revise the representation. Perhaps tell the truth first by giving the

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-16 Thread Terry J. Reedy
Terry J. Reedy added the comment: I agree that turning 'exit' and 'quit' into semi-keywords is not acceptible. I added this to my PR review. >>> exit = 3 >>> exit f:\dev\3x> -- ___ Python tracker

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-16 Thread Vedran Čačić
Vedran Čačić added the comment: > In the other hand, special-casing 'quit\n' and 'exit\n' could be seen as > analogous to special-casing '^Z\n' Terry, there is a big difference between special-casing 'exit\n' and special-casing '^Z\n': 'exit' is a perfectly valid identifier (and people use

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-16 Thread Terry J. Reedy
Terry J. Reedy added the comment: This has been proposed and rejected before. So I think a pydev discussion and steering council decision would be needed to change. The current rule in interactive mode is that typing an expression statement echoes the representation of the resulting

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-14 Thread Gregory P. Smith
Gregory P. Smith added the comment: Thanks Mark, that's a good real world experience example from the IPython side. -- ___ Python tracker ___

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-14 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Wed, Jul 14, 2021 at 08:10:51PM +, Aaron Meurer wrote: > There are already pseudo-keywords in the language, in particular, > super() super is not a pseudo-keyword. It's a regular builtin object that interacts with some (quite clever) compiler magic

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-14 Thread Mark Dickinson
Mark Dickinson added the comment: > the confusion that it can cause when there is a mismatch between the > interactive interpreter and noninteractive execution I've witnessed similar confusion when teaching, using IPython. After discovering that you can do In [1]: import pandas as pd

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-14 Thread Aaron Meurer
Aaron Meurer added the comment: When talking about making exit only work when typed at the interpreter, something to consider is the confusion that it can cause when there is a mismatch between the interactive interpreter and noninteractive execution, especially for novice users. I've seen

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-13 Thread Jack DeVries
Jack DeVries added the comment: I wonder if the middle ground here is to let it be a teachable moment, and to inform the user by having the string returned by __repr__ be a bit more descriptive. Currently, it is: > Use exit() or Ctrl-Z plus Return to exit I propose: > exit is the function

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-13 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Tue, Jul 13, 2021 at 01:58:30AM +, Taylor Alexander wrote: > I would push back against the idea that this is about laziness. It > sounds like this is about reducing user confusion. Users aren't *confused* by the instructions, which are clear and

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-13 Thread Gregory P. Smith
Change by Gregory P. Smith : -- stage: -> patch review type: behavior -> enhancement ___ Python tracker ___ ___ Python-bugs-list

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-13 Thread Gregory P. Smith
Gregory P. Smith added the comment: Agreed with Paul, this is a good idea UX wise for interactive interpreters. IPython proved that well over a decade ago. Thanks for the historical links! -- nosy: +gregory.p.smith ___ Python tracker

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-13 Thread Éric Araujo
Change by Éric Araujo : -- components: +Library (Lib) -Demos and Tools nosy: +eric.araujo ___ Python tracker ___ ___

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-13 Thread Paul Ganssle
Change by Paul Ganssle : -- stage: resolved -> ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-13 Thread Paul Ganssle
Paul Ganssle added the comment: Re-opening this because I think the discussion is not done and I don't see any reason why this was rejected. > Related 2005 python-dev discussion: > https://mail.python.org/archives/list/python-...@python.org/thread/VNGY2DLML4QJUXE73JLVBIH5WFBZNIKG/ @Mark

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-13 Thread Mark Dickinson
Mark Dickinson added the comment: and the related issue: https://bugs.python.org/issue1446372 -- ___ Python tracker ___ ___

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-13 Thread Mark Dickinson
Mark Dickinson added the comment: Related 2005 python-dev discussion: https://mail.python.org/archives/list/python-...@python.org/thread/VNGY2DLML4QJUXE73JLVBIH5WFBZNIKG/ -- nosy: +mark.dickinson ___ Python tracker

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-13 Thread Paul Ganssle
Paul Ganssle added the comment: At this point I think we should probably start a thread on python-dev to see how people feel about it. I'd be happy to author or co-author a PEP for this if need be. -- ___ Python tracker

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-13 Thread Paul Ganssle
Paul Ganssle added the comment: > In fact, you're proposing to use exit as a keyword, but lying about it to the > users. If it were really so important, then it _should_ be a keyword, and at > least I'd know that I can't use it for my variables anymore. (It's not the > first time such a

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-13 Thread Stargirl Flowers
Change by Stargirl Flowers : -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Vedran Čačić
Vedran Čačić added the comment: > based on feedback it seems that almost everyone expects "exit" to exit I don't, and I don't remember being asked. Let me be clear: if exit were a Python keyword, then maybe I would expect that. Or at least, I could convince myself to expect that. But exit is

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Taylor Alexander
Taylor Alexander added the comment: Am I correct in thinking that the proposed change only affects the use case where a user types exit in to the REPL and hits return? And that any other case is unaffected? I can only imagine that the majority of users who type exit in to the interpreter

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Stargirl Flowers
Stargirl Flowers added the comment: @steven.daprano I appreciate your perspective but you laid out a lot of strong opinions as if they're incontrovertible truths. The motivation here isn't laziness- I created this bug because I saw actual people across various skill levels that are bugged

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Thanks Steven for your input and your comments and for expressing your concerns. I will hold the PR then until there is consensus on how to proceed and all concerns are addressed (eventually closing it if there isn't consensus). I'm any case, I think

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: > Other than that, only arguments based on the purity of the language, > but I think having this working is far more important. Having this "working" is not important at all. This is precisely the sort of user-hostile anti-feature that we should avoid, not

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: Please don't do this. On Mon, Jul 12, 2021 at 02:19:58PM +, Pablo Galindo Salgado wrote: > >>> exit > bye! This is a user-hostile and unfriendly UI for Python. The Python REPL is not a shell like bash etc, it should be safe to evaluate any builtin

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Since Paul is +1 if another core dev (or devs) are +1 as well with the approach in PR27096 I would feel confident to proceed with this. Alternatively, we could discuss this more generally in python-dev if someone feels that we should have a more open

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > Are there any downsides to doing it this way? It seems tightly scoped and > with minimal overhead. We also need to support quit(), if we go this route. It makes parsing in the REPL a bit slower because it needs to check for this at every command

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Paul Ganssle
Paul Ganssle added the comment: I'm +1 for Pablo's approach. That's approximately what I meant by "special-case it in the REPL layer" anyway. Are there any downsides to doing it this way? It seems tightly scoped and with minimal overhead. -- ___

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Stargirl Flowers
Stargirl Flowers added the comment: Fair point about semantic behavior and complexity, but hopefully we can come up with a solution that's easier for users. I do like the PR suggested. -- ___ Python tracker

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > I do want to be cautious of saying that we can't do it because of the way the > REPL is currently implemented- which appears to be an implementation driven > by convenience more than necessity. Apologies if I have not been clear on this. Is not

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Stargirl Flowers
Stargirl Flowers added the comment: I do want to be cautious of saying that we can't do it because of the way the REPL is currently implemented- which appears to be an implementation driven by convenience more than necessity. I also find pushing against special-case behavior in the REPL

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: One thing we *could* do which is not super invasive, is to match a single AST node of type NAME at the end of Python run. This seems to work but is a bit inelegant: >>> print(exit) Use exit() or Ctrl-D (i.e. EOF) to exit >>> [exit] [Use exit() or

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- keywords: +patch pull_requests: +25644 stage: -> patch review pull_request: https://github.com/python/cpython/pull/27096 ___ Python tracker

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > would be in the REPL layer by special-casing `exit` Unfortunately, there is no REPL *layer* as my previous comments mentioned. There is a few details that change for interactive mode but fundamentally the pipeline is the same as reading from a

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Paul Ganssle
Paul Ganssle added the comment: If we want to confine the behavior to just the repl, we could possibly have the repl set an environment variable or something of that nature for interactive sessions, so that `__repr__` of `exit` can tell the difference between being invoked in a REPL and not

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: For reference, IPython has an entire interception + filtering mechanism to auto call certain functions: https://github.com/ipython/ipython/blob/0e4d6390b2174fb1b352a082b72ad387ae696e87/IPython/core/prefilter.py#L414-L425 where exit is one instance of

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: IPython and other reprs are an entire abstraction layer on top of Python, which allows them to do a lot of extra things like implement new commands and alters a lot of behaviours, but the CPython REPL is just the interpreter evaluating commands, and

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > However, I disagree that "exit" should not be a special case. But a special case of *what*? How would you implement this in a backwards-compatible way? -- ___ Python tracker

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Stargirl Flowers
Stargirl Flowers added the comment: Also, if a PEP is recommended, I will be happy to author it. -- ___ Python tracker ___ ___

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Stargirl Flowers
Stargirl Flowers added the comment: I don't think we should completely write off the possibility of doing this just because the *current* implementation is counter-intuitive. As I expressed in the original post, the explanation of this behavior is rather unsatisfying to newcomers. Also

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: This is a backwards-incompatible change, at the very least it needs an okay from the core devs (and possibly even a PEP) not just a patch. Stargirl Flowers suggested: > we could ask the user to confirm that they want to exit Please, no, that is the very

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Steven D'Aprano
Steven D'Aprano added the comment: I strongly oppose this change. Merely printing an object should not have a side-effect of this magnitude. Standard Python behaviour is that an object's repr should return a useful string, not exit the interpreter. This is a backwards-incompatible change:

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Taylor Alexander
Taylor Alexander added the comment: Makes sense. Thanks for taking a look. -- ___ Python tracker ___ ___ Python-bugs-list mailing

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Unfortunately, I don't know how that can help because the stack trace is the same in these two cases: >>> import traceback >>> class A: ... def __repr__(self): ... traceback.print_stack() >>> A() File "", line 1, in File "", line 4, in

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Taylor Alexander
Taylor Alexander added the comment: Hello all. Curious issue. Thanks Stargirl for opening it. Would it be possible for the __repr__ function to examine the calling commands and determine if the origin is the special case where exit is typed in the REPL? Then only when Quitter repr is called

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Vedran Čačić
Vedran Čačić added the comment: Of course, the "license" mention should be changed in the same way (in the same message). -- nosy: +veky ___ Python tracker ___

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-12 Thread Filipe Laíns
Change by Filipe Laíns : -- nosy: +FFY00 stage: -> needs patch type: -> behavior ___ Python tracker ___ ___ Python-bugs-list

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-11 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: For reference, this behaviour lives here: https://github.com/python/cpython/blob/e14d5ae5447ae28fc4828a9cee8e9007f9c30700/Lib/_sitebuiltins.py#L13-L26 -- ___ Python tracker

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-11 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Thanks, Stargirl for opening this issue and for the thorough description and proposals. I am sympathetic with the idea and the general proposal and (unsurprisingly) I agree with (1). For (2) there are some challenges here to consider. The most

[issue44603] REPL: exit when the user types exit instead of asking them to explicitly type exit()

2021-07-11 Thread Stargirl Flowers
New submission from Stargirl Flowers : Presently, when using REPL if a user types simply "exit", they are greeted with a message instructing them to do it "correctly": >>> exit Use exit() or Ctrl-Z plus Return to exit It comes across as a little surprising that (1) the program knows what I