The "loop and a half"
Steve D'Aprano
steve+python at pearwood.info
Sun Oct 8 05:12:26 EDT 2017
On Sun, 8 Oct 2017 02:06 am, bartc wrote:
>> On 2017-10-07, bartc <bc at freeuk.com> wrote:
>>
>>> Interactive Python requires quit() or exit(), complete with parentheses.
.......................^^^^^^^^^^^^^^^^^^^^^^^^^
>> Nonsense. On Unix you can just press ctrl-D (or whatever you have
>> configured as eof) at the command prompt. On windows, it's Ctrl-Z
>> <Enter>.
>
> Steve spoke about the 'usual quit/exit/bye' commands.
As well as Ctrl-D, EOF, which is a standard way to exit most Unix programs.
(Or as close as anything in Unix comes to a standard UI.)
> If you type 'quit' in interactive Python, then it says:
>
> Use quit() or Ctrl-Z plus Return to exit
>
> Same for exit. So in Python, IF you want to use quit or exit to
> terminate, you have to use quit() or exit() instead.
>
> So please explain how what I wrote was nonsense.
Do you still believe that quit/exit is REQUIRED?
To be pedantic, we have at least seven ways:
- EOF (Ctrl-D on Unix, Ctrl-Z ENTER on Windows);
- calling quit() or exit();
- raise SystemExit;
- call sys.exit()
- call os._exit();
- call os.abort();
- write your own custom quitter object that exits on simply being
printed, e.g.:
class Bye:
def __repr__(self):
sys.exit(0)
bye = Bye()
Four of these are intended for programmatic use, but they work interactively
as well. At least two of them shouldn't be used unless you know what you are
doing (os._exit and os.abort).
>>> Unless you've redefined quit and exit as something else, then you have
>>> to crash out by other means.)
>>
>> Admit it, you're just trolling.
>
> FFS, NOW what's wrong?
"Crash out".
> IF you DO redefine those names, then you DO have to use other means to
> terminate. I happen to call those means 'crashing out', because it's
> like yanking the plug rather than using the on/off switch.
os._exit and os.abort (especially the second) could legitimately be described
as "crashing out". The others, not within a million miles of it.
> Especially on
> Windows where the usual Ctrl C doesn't work, so you resort to Ctrl-Break
> will which actually abort it. Ctrl Z is uncommon.
Thousands of Python programmers on Windows successfully learned to use Ctrl-Z
ENTER back in the days of Python 1.5, before quit/exit were added as a
convenience for beginners, and many of them probably still use it.
Yet again you assume that because YOU don't do something, nobody else in the
world could possibly do it.
> I'm getting fed up with this thread now.
This thread would be a lot less frustrating if you would enter into it with a
spirit of open-minded enquiry rather than an overbearing sense of superiority
that anything others do that you don't must be worthless.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
More information about the Python-list
mailing list