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

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Matt Chaput (mchaput)
Assigned to: Nobody/Anonymous (nobody)
Summary: quit should quit

Initial Comment:
When the user types "quit" in the interpreter, instead
of quitting the program gives him or her a lecture on
the "proper" way to quit.

This is very obnoxious.

Since the interpreter obviously understands the "quit"
command, it should just quit, dammit.

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

>Comment By: Armin Rigo (arigo)
Date: 2005-04-01 11:12

Message:
Logged In: YES 
user_id=4771

This discussion keeps coming up time and again.  sjoerd's trick has been tried 
a few times already, until people implementing it realized that trying to 
display the builtins dict (directly or indirectly) would quit the interpreter!

'quit' cannot just be a synonym for 'sys.exit' either, because typing 'quit' 
would just print '<built-in function quit>', which is worse than the current 
situation in term of expliciteness.

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

Comment By: Sjoerd Mullender (sjoerd)
Date: 2005-04-01 11:04

Message:
Logged In: YES 
user_id=43607

Something like this instead of the current quit should do
the trick:

class Quit:
    def __repr__(self):
        import sys
        sys.exit(0)
quit = Quit()
del Quit

The problem with the Raymond's suggestion is that you need
to type parentheses.
But of course, this does get a little magical...

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

Comment By: Raymond Hettinger (rhettinger)
Date: 2005-04-01 06:14

Message:
Logged In: YES 
user_id=80475

'quit' and 'exit' currently show-up in a dir() of__builtins__.  

If the OP's suggestion is accepted, it should probably be 
implemented just like a builtin:

    def quit():
        sys.exit()

That approach is not at all magical and still allows shadowing 
(quit=2, etc.)

What we have now is an annoying wart.

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

Comment By: Ilya Sandler (isandler)
Date: 2005-04-01 04:35

Message:
Logged In: YES 
user_id=971153

I am not sure adding quit to interpreter is such a good idea:

Right now quit is treated as an ordinary (non-keyword)
identifier...
(with a bit of magic: if quit is not defined then lecture
the user :-))...

E.g now you can do this:

 >>> quit=2 
 >>> quit
 2

Would you want to disallow this usage when quit becomes a
"magic word"?



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

Comment By: Michael Hudson (mwh)
Date: 2005-03-31 09:49

Message:
Logged In: YES 
user_id=6656

I'm not so sure typing quit should quit -- that doesn't seem like Python to 
me (how would you implement it?)

Having quit be the same object as sys.exit seems sensible.

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

Comment By: Raymond Hettinger (rhettinger)
Date: 2005-03-30 22:11

Message:
Logged In: YES 
user_id=80475

I concur!

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1173637&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to