What should Python apps do when asked to show help?

Steven D'Aprano steve at pearwood.info
Fri Apr 29 21:20:21 EDT 2016


On Fri, 29 Apr 2016 07:53 pm, Rustom Mody wrote:

> On Friday, April 29, 2016 at 3:07:09 PM UTC+5:30, Steven D'Aprano wrote:
>> On Fri, 29 Apr 2016 03:00 pm, Rustom Mody wafted information-rich
>> pheromones into the air, where they diffused rapidly:
>> > Why replicate and cause annoyance?
>> 
>> If you don't want to use the functionality, don't.
> 
> You asked about calling up pagers!!

Right. And options -h/--help will behave exactly as people have requested,
by printing to stdout.


> JFTR I find git behavior annoying -- as it seems do others

`git --help` behaves as the Unix standard: it prints help output to stdout.
Is that the annoying behaviour?

`git help <command>` and `git <command> --help` call `man`. Is that the
annoying behaviour? Then presumably `man` is also annoying, and the advise
I was given to just use man pages is bad advice.


> -- but Ive 
> figured getting round it by calling it with -w (show in web browser) is ok
> (with me)

You would rather output be shown in a web browser than paged in your
terminal? That's weird, but okay, whatever floats your boat.


> With python's help I find it annoying and Ive not figured out how to not
> get paging

o_O

Okay, now I'm feeling as if you had said "I find it annoying to be fit and
healthy, I've not found a way to feel sufficiently sick, tired and
out-of-shape all the time."

But I see your point. The pydoc documentation itself is lacking. But from
reading the source code, I see that if you set the PAGER environment
variable to your preferred pager, it will use that. So setting it to "cat"
should work. I've just tested this under Linux, and it works for me:


[steve at ando ~]$ PAGER=cat python3.3
Python 3.3.0rc3 (default, Sep 27 2012, 18:44:58)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux
Type "help", "copyright", "credits" or "license" for more information.
py> help(len)
Help on built-in function len in module builtins:

len(...)
    len(object) -> integer

    Return the number of items of a sequence or mapping.

py>



-- 
Steven




More information about the Python-list mailing list