Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quit should quit #41780

Closed
mchaput mannequin opened this issue Mar 30, 2005 · 11 comments
Closed

quit should quit #41780

mchaput mannequin opened this issue Mar 30, 2005 · 11 comments

Comments

@mchaput
Copy link
Mannequin

mchaput mannequin commented Mar 30, 2005

BPO 1173637
Nosy @mwhudson, @loewis, @sjoerdmullender, @arigo, @rhettinger

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2005-04-17.10:42:38.000>
created_at = <Date 2005-03-30.21:37:00.000>
labels = []
title = 'quit should quit'
updated_at = <Date 2005-04-17.10:42:38.000>
user = 'https://bugs.python.org/mchaput'

bugs.python.org fields:

activity = <Date 2005-04-17.10:42:38.000>
actor = 'pernici'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['None']
creation = <Date 2005-03-30.21:37:00.000>
creator = 'mchaput'
dependencies = []
files = []
hgrepos = []
issue_num = 1173637
keywords = []
message_count = 11.0
messages = ['24829', '24830', '24831', '24832', '24833', '24834', '24835', '24836', '24837', '24838', '24839']
nosy_count = 8.0
nosy_names = ['mwh', 'loewis', 'sjoerd', 'arigo', 'rhettinger', 'isandler', 'mchaput', 'pernici']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1173637'
versions = []

@mchaput
Copy link
Mannequin Author

mchaput mannequin commented Mar 30, 2005

When the user types "quit" in the interpreter, instead
of quitting the program gives him or her a lecture on
the "proper" way to quit.

This is very obnoxious.

Since the interpreter obviously understands the "quit"
command, it should just quit, dammit.

@mchaput mchaput mannequin closed this as completed Mar 30, 2005
@rhettinger
Copy link
Contributor

Logged In: YES
user_id=80475

I concur!

@mwhudson
Copy link

Logged In: YES
user_id=6656

I'm not so sure typing quit should quit -- that doesn't seem like Python to
me (how would you implement it?)

Having quit be the same object as sys.exit seems sensible.

@isandler
Copy link
Mannequin

isandler mannequin commented Apr 1, 2005

Logged In: YES
user_id=971153

I am not sure adding quit to interpreter is such a good idea:

Right now quit is treated as an ordinary (non-keyword)
identifier...
(with a bit of magic: if quit is not defined then lecture
the user :-))...

E.g now you can do this:

 >>> quit=2 
 >>> quit
 2

Would you want to disallow this usage when quit becomes a
"magic word"?

@rhettinger
Copy link
Contributor

Logged In: YES
user_id=80475

'quit' and 'exit' currently show-up in a dir() of__builtins__.

If the OP's suggestion is accepted, it should probably be
implemented just like a builtin:

    def quit():
        sys.exit()

That approach is not at all magical and still allows shadowing
(quit=2, etc.)

What we have now is an annoying wart.

@sjoerdmullender
Copy link
Member

Logged In: YES
user_id=43607

Something like this instead of the current quit should do
the trick:

class Quit:
    def __repr__(self):
        import sys
        sys.exit(0)
quit = Quit()
del Quit

The problem with the Raymond's suggestion is that you need
to type parentheses.
But of course, this does get a little magical...

@arigo
Copy link
Mannequin

arigo mannequin commented Apr 1, 2005

Logged In: YES
user_id=4771

This discussion keeps coming up time and again. sjoerd's trick has been tried a few times already, until people implementing it realized that trying to display the builtins dict (directly or indirectly) would quit the interpreter!

'quit' cannot just be a synonym for 'sys.exit' either, because typing 'quit' would just print '<built-in function quit>', which is worse than the current situation in term of expliciteness.

@rhettinger
Copy link
Contributor

Logged In: YES
user_id=80475

class quit:
    def __repr__(self):
        return "Type quit() to exit the interpreter"
    def __call__(self):
        sys.exit()

Requiring the parentheses is not a big deal as long as there
is an advisory where they are omitted.

@loewis
Copy link
Mannequin

loewis mannequin commented Apr 1, 2005

Logged In: YES
user_id=21627

But how is this better than the current

>>> quit
'Use Ctrl-D (i.e. EOF) to exit.'

I'd rather learn that I have to type Ctrl-D instead of
typing quit()

I think the original report is misguided: The interpreter
does not "obviously understand" the quit command. Instead,
it really does not understand it all. The name quit is bound
to a string, and the interpreter displays the string. It
does not understand at all what the string says.

So I'm rejecting the report as "won't fix".

@arigo
Copy link
Mannequin

arigo mannequin commented Apr 2, 2005

Logged In: YES
user_id=4771

Raymond, an argument against quit() actually quitting the interpreter is that it suddenly makes quit() a quasi-official piece of the Python API, and we're bound to see user programs start to write quit() instead of sys.exit().

@pernici
Copy link
Mannequin

pernici mannequin commented Apr 17, 2005

Logged In: YES
user_id=756712

To allow the builtin quit() only when using
Python interactively, one can put in a start-up quitfile.py

def quit():
  import sys
  sys.exit(0)

and set
export PYTHONSTARTUP=quitfile.py
One could add to this file also
exit = quit
since the builtin exit behaves like quit.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants