[Python-Dev] a quit that actually quits (original) (raw)

Ka-Ping Yee python-dev at zesty.ca
Tue Dec 27 23:57:54 CET 2005


It sounds to me like what is being proposed amounts to essentially "promote sys.exit to a builtin". So why not do that?

I see two options. Either:

(a) Simply let __builtins__.exit = sys.exit.  Then we get:

    >>> exit
    <built-in function exit>

    which may be enough of a clue that you type "exit()" to exit.

(b) If more handholding seems like a good idea, then:

    class ExitHatch:
        def __call__(self): sys.exit()
        def __repr__(self): return '<Type "exit()" to exit Python.>'
    __builtins__.exit = __builtins__.quit = ExitHatch()

-- ?!ng



More information about the Python-Dev mailing list