[ python-Bugs-1600157 ] [PATCH] Quitting The Interpreter

SourceForge.net noreply at sourceforge.net
Tue Nov 21 10:47:44 CET 2006


Bugs item #1600157, was opened at 2006-11-21 03:52
Message generated for change (Comment added) made by mwh
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1600157&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: None
>Status: Closed
>Resolution: Rejected
Priority: 9
Private: No
Submitted By: Chris Carter (cdcarter)
>Assigned to: Michael Hudson (mwh)
Summary: [PATCH] Quitting The Interpreter

Initial Comment:
When i type 'quit' in the interpreter, i get a nice little class and method yelling at me, instead of just quitting.

PATCH:
<pre>
def setquit():

    class Quitter(object):
        def __init__(self, name):
            self.name = name
        def __repr__(self):
            quit()
        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)
    __builtin__.quit = Quitter('quit')
    __builtin__.exit = Quitter('exit')
</pre>

----------------------------------------------------------------------

>Comment By: Michael Hudson (mwh)
Date: 2006-11-21 09:47

Message:
Logged In: YES 
user_id=6656
Originator: NO

Think what happens when you type 'print __builtin__.__dict__'.

This has been proposed and rejected many times before, please search the
python-dev archives for more.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1600157&group_id=5470


More information about the Python-bugs-list mailing list