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
Comments
When the user types "quit" in the interpreter, instead This is very obnoxious. Since the interpreter obviously understands the "quit" |
Logged In: YES I concur! |
Logged In: YES I'm not so sure typing quit should quit -- that doesn't seem like Python to Having quit be the same object as sys.exit seems sensible. |
Logged In: YES I am not sure adding quit to interpreter is such a good idea: Right now quit is treated as an ordinary (non-keyword) E.g now you can do this: >>> quit=2
>>> quit
2 Would you want to disallow this usage when quit becomes a |
Logged In: YES 'quit' and 'exit' currently show-up in a dir() of__builtins__. If the OP's suggestion is accepted, it should probably be def quit():
sys.exit() That approach is not at all magical and still allows shadowing What we have now is an annoying wart. |
Logged In: YES Something like this instead of the current quit should do 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 |
Logged In: YES 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. |
Logged In: YES 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 |
Logged In: YES 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 I think the original report is misguided: The interpreter So I'm rejecting the report as "won't fix". |
Logged In: YES 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(). |
Logged In: YES To allow the builtin quit() only when using def quit():
import sys
sys.exit(0) and set |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: