diff options
author | Georg Brandl <georg@python.org> | 2006-03-09 23:22:06 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-03-09 23:22:06 (GMT) |
commit | 24cb053b158a3cd63f7be05ac27f47e45bb2f1b3 (patch) | |
tree | 7f13771e5cc4d4641cb8227812ae6dd69c8519db /Lib/site.py | |
parent | ca4d08b6d366ef12022c15ea546ecf7a19a087e7 (diff) | |
download | cpython-24cb053b158a3cd63f7be05ac27f47e45bb2f1b3.zip cpython-24cb053b158a3cd63f7be05ac27f47e45bb2f1b3.tar.gz cpython-24cb053b158a3cd63f7be05ac27f47e45bb2f1b3.tar.bz2 |
Patch #1446372: quit and exit can now be called from the interactive
interpreter to exit.
Diffstat (limited to 'Lib/site.py')
-rw-r--r-- | Lib/site.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Lib/site.py b/Lib/site.py index 2207ec5..3fc7537 100644 --- a/Lib/site.py +++ b/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): |