[Python-Dev] a quit that actually quits
Jeremy Kloth
jeremy.kloth at fourthought.com
Wed Dec 28 11:29:16 CET 2005
Ka-Ping Yee wrote:
> I'd be happy with having Python exit when the user types just plain
> 'exit' without parentheses, but only in that case, not others.
> However, i'm starting to think that may be impossible to implement.
> I can't think of any way to make 'print exit' not exit, for example.
OK, here's one:
def quithook(obj, _exit=__builtins__.exit, _displayhook=sys.displayhook):
if obj is _exit: raise SystemExit
_displayhook(obj)
sys.displayhook = quithook
It does, however, fall into the whole issue of chaining that Skip brought up
earlier.
--
Jeremy Kloth
Fourthought, Inc.
http://fourthought.com/
http://4suite.org/
More information about the Python-Dev
mailing list