The "loop and a half"

Chris Angelico rosuav at gmail.com
Thu Oct 5 21:45:37 EDT 2017


On Fri, Oct 6, 2017 at 12:07 PM, Steve D'Aprano
<steve+python at pearwood.info> wrote:
> But in fairness, if the author of the `sort` command had a commitment to
> friendliness in their programs, they could have `sort` only print a message
> when it is reading from stdin and writing to stdout, much as `ls` defaults to
> outputting control characters but automatically swaps to replacing them
> with ? when writing to a terminal.
>
> I believe that even Unix experts would be more effective with a judicious
> amount of not so much hand-holding as gentle guidance. Even experts aren't
> expert on every single command line tool.

It's not as simple as that, because you can't always know whether
you're working with a console or a pipe. And it gets annoying when you
have to force some program to behave interactively when it thought you
were piping it into something, or vice versa.

The sort program is *usually* reading from stdin and writing to
stdout. Did you mean "reading from a TTY and writing to a TTY"? That's
the nearest, but it's still not perfect.

ChrisA



More information about the Python-list mailing list