The "loop and a half"
bartc
bc at freeuk.com
Sat Oct 7 10:15:32 EDT 2017
On 07/10/2017 14:19, Steve D'Aprano wrote:
> On Sat, 7 Oct 2017 11:06 pm, bartc wrote:
>> So I have to copy 33,000 lines from a document,
>
> Don't be daft. Nobody says that stdin is a sufficient interface for a
> heavy-weight task like that. With 33000 lines of text, I absolutely would
> save them to a permanent file on disk, because I wouldn't want to risk having
> the application crash or the power go off just as I've typed line 32999 and
> lose the lot.
You're missing something I think. The 33K lines already exist elsewhere,
and have been copied to the clipboard. So you won't lose anything if the
power goes off, assuming the original are secure.
> For 33000 lines, having one extra temporary file floating around is a cost
> worth paying. For 33 lines, it is not.
I was demonstrating the crudeness of copying and pasting to a console
window rather than between proper applications. That was easier to show
with a larger example which highlighted some of the practical aspects.
> You want a one-size fits all solution. Are you capable of understanding that
> different tasks and different scenarios are often best solved using different
> techniques?
>
>
> [...]
>> Put that way, it doesn't sound very sophisticated does it?
>
> Nobody said it was sophisticated. That's the whole point: having sort read
> from stdin as you type into the terminal is the LEAST sophisticated,
> simplest, most bare-bones, basic technique that works.
You do remember this was about using programs /like/ sort as a model for
writing true interactive scrolling text apps?
I said it was a poor model because sort is normally used with files and
pipes. You're trying to keep it as a viable model because, sometimes,
sort can also be used with pasted text which sort reads as as though it
had been typed in real time (not from a pipe or file anyway).
OK, I'm not suggesting doing away with that.
But it is still a bad model of text application to use elsewhere, even
if extra prompts were added. For one thing, it only reads one block of
data, then it stops. A more typical text application will be doing
different things requiring different entry modes.
--
bartc
--
bartc
More information about the Python-list
mailing list