[Python-Dev] a quit that actually quits

Stephen J. Turnbull stephen at xemacs.org
Fri Dec 30 06:14:31 CET 2005


>>>>> "Nick" == Nick Coghlan <ncoghlan at gmail.com> writes:

    Nick> Samuele Pedroni wrote:

    >> It's not a matter of defending the status quo, more about what
    >> kind of price is reasonable for DWIM.

IMHO, +N*10^6 for simplicity, regularity, and discoverability, -1 for
DWIM in the interpreter.  DWIM is for wrappers, interactive tutorials,
and IDEs.

    Nick> I think Fredrik has made an excellent case for promoting the
    Nick> quit & exit interpreter-only builtins to be proper
    Nick> callables.

No, Fredrik has made a good (but not good enough!) case for making
them syntax (or for adding the concept of "interpreter command" to the
specification), but your own example of "license" works against you
for callables:

    Nick> Hell, we even have that capability for the callable that
    Nick> displays the *license* text. . . surely quitting the
    Nick> interpreter is far more important than being able to display
    Nick> the license text, but the support for the latter is
    Nick> significantly better:

  Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32
  Type "help", "copyright", "credits" or "license" for more information.
  Py> license
  Type license() to see the full license text
  Py>

Now, unlike the case of quit, where the user did something
undocumented (albeit "natural") that really is rude (and its semantics
are no "better" than the support for quit).  (Example edited to
enhance the effect.)  I do think it's reasonable that those callables
be somewhat python-newbie-friendly.  What I would want to see is

papa% python
Python 2.4.2 (#1, Dec 23 2005, 01:55:50) 
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type "help()", "copyright()", "credits()" or "license()" for more information.
Type EOF (Ctrl-D) to end the interpreter session.
>>> help
Type "help()".
In Python, work is done by function calls, not statements or commands.
This message is the printable representation of the help object.
>>> help()
You may exit the interpreter with an EOF (Ctrl-D), or by calling a system
function or raising an appropriate exception.
[ ... etc, etc, ... ]
>>> 

copyright, credits, license, quit, and exit would be treated similarly
(except maybe they should not be quite so "educational," just the
brief reminder 'Type "<callable>()".  Type "help()" for help.' should
be enough).  I definitely don't think help() should advertise exit(),
as it is too similar to sys.exit().  I'm -1 on quit() being
advertised because I'm -1 on DWIM in principle, but if DWIM is
accepted for this purpose, I don't see practical harm in advertising it.

IMO, in the end making "quit" callable really isn't responsive to
Fredrik's point.  Which is AIUI that most interactive shells do have a
quit command, and newbies are going to expect Python to have one, too.

-- 
School of Systems and Information Engineering http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.


More information about the Python-Dev mailing list