Skip to content

Commit d89fa0c

Browse files
committed
Add built-in string variables 'quit' and 'exit' that display a hint on
how to exit (in a platform dependent way!). We use os.sep to determine which platform we're on, since I expect that this will work better for minority platforms.
1 parent aee5e26 commit d89fa0c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Lib/site.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,18 @@ def addpackage(sitedir, name):
107107
if os.path.isdir(sitedir):
108108
addsitedir(sitedir)
109109

110+
# Define new built-ins 'quit' and 'exit'.
111+
# These are simply strings that display a hint on how to exit.
112+
if os.sep == ':':
113+
exit = 'Use Cmd-Q to quit.'
114+
elif os.sep == '\\':
115+
exit = 'Use Ctrl-Z plus Return to exit.'
116+
else:
117+
exit = 'Use Ctrl-D (i.e. EOF) to exit.'
118+
import __builtin__
119+
__builtin__.quit = __builtin__.exit = exit
120+
del exit
121+
110122
try:
111123
import sitecustomize # Run arbitrary site specific code
112124
except ImportError:

0 commit comments

Comments
 (0)