Interactive scripts (back on topic for once) [was Re: The "loop and a half"]

Paul Moore p.f.moore at gmail.com
Fri Oct 6 05:27:42 EDT 2017


On 6 October 2017 at 10:14, Marko Rauhamaa <marko at pacujo.net> wrote:
> Generally, you shouldn't condition the program too much on such
> environmental details, although it is done. For example, the "ls"
> command outputs the directory listing in a (colorful) multi-column
> format when stdout is a terminal and in a (b/w) one-file-per-line format
> otherwise.

Agreed that any behaviour of the program should be explicitly
controllable by command line arguments and/or configuration. But IMO,
it's perfectly OK for the *default* behaviour to be affected by the
environment, as long as that's done in a way that provides a good user
experience. Of course, what constitutes a "good UX" is a judgement
call... (Personally I think ls goes too far in how different it is in
the interactive case, for example).

Paul


>
> Since such guesswork often goes wrong, the program should provide
> command-line options to specify the operating mode explicitly. The "ls"
> command has "--color" and "--format". The "ssh" command has "-o
> BatchMode=yes" and so on.
>
> Again, the Unix way is to preferably stay silent by default. If you want
> the program to chat, there is "--verbose".
>
>
> Marko
> --
> https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list