The "loop and a half"

Steve D'Aprano steve+python at pearwood.info
Fri Oct 6 21:46:14 EDT 2017


On Sat, 7 Oct 2017 06:18 am, bartc wrote:

> For sort, there is no real need. You use a text editor to create your
> data. Then use existing file-based sort.

What you mean is, *you* see no need for sorting interactively, or sorting as
part of a pipeline of functions. That speaks more of your lack of imagination
and closed-mindedness than any real lack.

Personally, if I have a few (say, a dozen or so) lines I want sorted, it is
much easier to:

- select text from whatever application I'm using;

- bring up a terminal (I almost always have one already open);

- type `sort ENTER`;

- middle-click to paste the lines;

- type Ctrl-D;

- select the output lines;

- paste back into the original application;


(seven steps)


versus:

- select text from whatever application I'm using;

- open a text editor;

- paste into the text editor;

- hit Ctrl-S to save;

- think of a file name ("temp123");

- type it in the file save dialog;

- click SAVE to save;

- invariably the file name is already used from the previous time I 
  needed a temporary file and forgot to delete it afterwards;

- so look more carefully at the existing files, and think of a new name;

- edit the file name;

- click SAVE again;

- open an external sort program (do I even have one? what's it called again?);

- in the sort program, whatever it is called, type Ctrl-O to open;

- navigate to the directory I saved the temp file;

- open that file;

- sort the file;

- save the output;

- type Ctrl-Q to quit;

- go back to the editor;

- select the File > Reload menu command to reload the now sorted file;

- select the text;

- go back to the application I started with;

- paste;

- go back to the editor and hit Ctrl-Q to quit;

- go to a file manager;

- locate the temporary file;

- hit backspace to send it to the trash

(27 steps).


Yes, I can certainly see why you prefer that second work-flow to the first.
Its so much more inefficient than memorising "Ctrl-D for EOF".

I forget... it is "work harder, not smarter"? Being inefficient is a good
thing, right? 



-- 
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