()
Define new built-ins 'quit' and 'exit'.
    These are simply strings that display a hint on how to exit.
Define new built-ins 'quit' and 'exit'.
    These are simply strings that display a hint on how to exit.
Define new built - ins quit and exit . These are simply strings that display a hint on how to exit .
def setquit():
    """Define new built-ins 'quit' and 'exit'.
    These are simply strings that display a hint on how to exit.

    """
    if os.sep == ":":
        eof = "Cmd-Q"
    elif os.sep == "\\":
        eof = "Ctrl-Z plus Return"
    else:
        eof = "Ctrl-D (i.e. EOF)"

    class Quitter(object):
        def __init__(self, name):
            self.name = name

        def __repr__(self):
            return "Use {}() or {} to exit".format(self.name, eof)

        def __call__(self, code=None):
            # Shells like IDLE catch the SystemExit, but listen when their
            # stdin wrapper is closed.
            try:
                sys.stdin.close()
            except:
                pass
            raise SystemExit(code)

    builtins.quit = Quitter("quit")
    builtins.exit = Quitter("exit")
def setquit ( ) : if os . sep == ":" : eof = "Cmd-Q" elif os . sep == "\\" : eof = "Ctrl-Z plus Return" else : eof = "Ctrl-D (i.e. EOF)" class Quitter ( object ) : def __init__ ( self , name ) : self . name = name def __repr__ ( self ) : return "Use {}() or {} to exit" . format ( self . name , eof ) def __call__ ( self , code = None ) : # Shells like IDLE catch the SystemExit, but listen when their # stdin wrapper is closed. try : sys . stdin . close ( ) except : pass raise SystemExit ( code ) builtins . quit = Quitter ( "quit" ) builtins . exit = Quitter ( "exit" )