mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Patch #1446372: quit and exit can now be called from the interactive
interpreter to exit.
This commit is contained in:
parent
ca4d08b6d3
commit
24cb053b15
2 changed files with 16 additions and 4 deletions
17
Lib/site.py
17
Lib/site.py
|
@ -227,12 +227,21 @@ def setquit():
|
|||
|
||||
"""
|
||||
if os.sep == ':':
|
||||
exit = 'Use Cmd-Q to quit.'
|
||||
eof = 'Cmd-Q'
|
||||
elif os.sep == '\\':
|
||||
exit = 'Use Ctrl-Z plus Return to exit.'
|
||||
eof = 'Ctrl-Z plus Return'
|
||||
else:
|
||||
exit = 'Use Ctrl-D (i.e. EOF) to exit.'
|
||||
__builtin__.quit = __builtin__.exit = exit
|
||||
eof = 'Ctrl-D (i.e. EOF)'
|
||||
|
||||
class Quitter(object):
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
def __repr__(self):
|
||||
return 'Use %s() or %s to exit' % (self.name, eof)
|
||||
def __call__(self, code=None):
|
||||
raise SystemExit(code)
|
||||
__builtin__.quit = Quitter('quit')
|
||||
__builtin__.exit = Quitter('exit')
|
||||
|
||||
|
||||
class _Printer(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue