What should Python apps do when asked to show help?

Chris Angelico rosuav at gmail.com
Thu Apr 28 13:06:22 EDT 2016


On Fri, Apr 29, 2016 at 2:33 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> I have an application written in Python which accepts -h or --help to show
> help. I can:
>
> (1) print the help text to stdout;
>
> (2) run the help text through a pager;
>
> (3) do something else?
>
>
> Many command line tools simply output help to stdout (or stderr, if they're
> evil),

I'm not sure stderr is particularly more evil than stdout, but whatever :)

What you could do is run the help text through a pager only if stdout
is a TTY. That allows it to be grepped conveniently, but also browsed
easily. But I wouldn't worry about that unless you have at least 3-5
pages of screed - for most programs, just dumping the text to a
standard stream is usually enough.

ChrisA



More information about the Python-list mailing list