The "loop and a half"

Gregory Ewing greg.ewing at canterbury.ac.nz
Thu Oct 5 18:42:20 EDT 2017


bartc wrote:
> It can be done with an in-band end-of-data code,

Then you need some way of escaping that in-band code, in case
it happens to equal some of the data you want to sort. And
you need to ensure that your input is escaped properly.
All of which adds a lot of complexity.

> Yes, I tried typing 'sort' in Linux, where it apparently hangs (same on 
> Windows actually). The reason: because it might have killed someone to 
> have added a message saying what you are expected to type and how to end 
> it. (Namely, press Ctrl-D start at the start of a line in Linux, and 
> Ctrl-Z followed by Enter, I think also at the start, in Windows.)

How to signal EOF from the keyboard is a fundamental piece
of knowledge about the OS. It's not the responsibility of
individual programs to teach it to you, any more than it's
your car's responsibility to explain what the steering wheel
does each time you start the engine.

-- 
Greg



More information about the Python-list mailing list