[Python-ideas] exit as a statement
Calvin Spealman
ironfroggy at socialserve.com
Wed Feb 20 16:51:56 CET 2008
This has been discussed to death several times before. I remember the
rationale against doing something different to have various reasons.
No one likes adding statements, for one thing (we have a tendency to
move things out of keyword-space, not into it). Another solution was
to define an ExitType with __str__ defined to raise SystemExit, but
then what happens if you just do something to dump a bunch of
objects? In other words: a side effect exiting is dangerous.
As far as an actual statement, I'd definitely be -1 with a single
exception. Would it be possible to define exit as an interpreter
command, so long as the name 'exit' is not bound to anything but the
exit str? In other words, it would only actually exit when you are in
the interpreter, not when executing scripts or modules.
On Feb 20, 2008, at 10:22 AM, BJörn Lindqvist wrote:
> An idea I have thought about for a while and it makes sense to me...
>
> $ python
> Python 2.4.2 (#1, Oct 13 2006, 17:17:08)
> [GCC 4.1.0 (SUSE Linux)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> exit
> 'Use Ctrl-D (i.e. EOF) to exit.'
>
> Argh! Do what I mean, stupid Python! And it is Ctrl+Z on Windows, not
> Ctrl-D. So exit could be a statement that does the same thing that
> sys.exit() does currently. Bare "exit" to terminate with return code
> 0, and "exit X" to terminate with return code X.
>
>
> --
> mvh Björn
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
More information about the Python-ideas
mailing list