Having a builtin exit function in python interpreter

Steven D. Majewski sdm7g at Virginia.EDU
Tue Nov 6 20:01:31 CET 2001


You could also do something like:

>>> class Quitter:
...     def __repr__(self):
...             ans = raw_input( 'Do you *REALLY* want to Quit? [Y/N]:' )
...             if ans[0] in ( 'Y', 'y' ) : raise SystemExit
...             return 'type ^Z to quit' 
... 
>>> __builtins__.quit = __builtins__.exit = __builtins__.q = Quitter()
>>> del Quitter
>>> 
>>> q
Do you *REALLY* want to Quit? [Y/N]:n
type ^Z to quit
>>> exit
Do you *REALLY* want to Quit? [Y/N]:n
type ^Z to quit
>>> quit
Do you *REALLY* want to Quit? [Y/N]:y
% 






More information about the Python-list mailing list