Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #107927

Re: What should Python apps do when asked to show help?

From cs@zip.com.au
Newsgroups comp.lang.python
Subject Re: What should Python apps do when asked to show help?
Date 2016-05-01 09:51 +1000
Message-ID <mailman.274.1462061343.32212.python-list@python.org> (permalink)
References <5724253e$0$22142$c3e8da3$5496439d@news.astraweb.com> <20160430235132.GA83556@cskk.homeip.net>

Show all headers | View raw


On 30Apr2016 13:23, Steven D'Aprano <steve@pearwood.info> wrote:
>On Sat, 30 Apr 2016 12:49 pm, Ben Finney wrote:
>> Random832 <random832@fastmail.com> writes:
>>> On Fri, Apr 29, 2016, at 22:27, Rustom Mody wrote:
>>> > Instead it does some ½-assed fall-between-the-stools of both
>>>
>>> That doesn't answer the question of why, if you (Well, Ethan, but
>>> you're taking the same position here) hate pagers so much
>>
>> That's not a question relevant here; nobody inthe discussion has a
>> position fairly characterised as “hate pagers so much”. So you're
>> arguing against a straw man.
>>
>> Rather, the position being argued is that they *do* like pagers; they
>> like pagers enough that they want the existing ‘PAGER’ environment
>> variable setting to remain untouched.
>
>So they want the PAGER environment variable to specify what pager they
>want...

_When_ they want a pager.

>> And, simulatenously, they want
>> Python's help to not use a pager at the interactive prompt.
>
>...so long as applications don't actually make use of that PAGER environment
>variable to determine the pager they want to use.

_When_ it is asked to use a pager.

What they (and, very often, me) want is that most things, including pydoc, to 
_NOT_ invoke a pager automatically, _unasked_.

So tools which page without asking are unwelcome, because that requires a mode 
switch when everything else (sed/grep/print/write/ls) do straight up unpaged 
output.

>(1) If you want man, and nothing else in the universe, to automatically use
>a pager, then set MANPAGER="less" (or whatever you wish to use), and unset
>PAGER.
>
>(2) If you don't want *anything* to use a pager, then unset both MANPAGER
>and PAGER. You may have to report a feature request / bug report for
>applications which force their own pager.
>
>(3) In Python specifically, you can trivially and easily tell help() to
>output directly to stdout. (At least on Linux, I haven't tested it
>elsewhere.) Simply use PAGER=cat on the command line you use to launch the
>interactive environment. This will affect no other running or future
>processes (apart from subprocesses launched from your interactive Python
>session), allowing you to keep your PAGER for everything else.
>
>(4) If you want more than that, then patches are welcome :-)

This requires terrible domain specific knowledge. What about programs other 
than man?

And setting PAGER=cat before invoking interactive python is no better, because 
it will screw with $PAGER in any subprocess spawned from that environment.

What those of use in the "my terminal emulator scrolls nicely thank you" camp 
want is that most command line things, when asked to simply print some help 
text, _print_ it and do not page it. And often would like a way to tell pydoc 
to not page, such as a pydoc specific switch (possibly an environment 
variable).

>Seriously, I'm thinking that a keyword argument to help might be useful:
>
>help(object, pager=None)
>
>where:
>- pager=None gives the current behaviour;
>- pager="foo" calls out to the external program "foo";
>- pager=callable passes the help text to callable().

I'd be asking for pager=None to look at help.default_pager, which itself might 
obey your rules above. That way help.default_pager can be a callable which 
consults $PAGER or falls back to some inbuilt pager (presumably as now), but 
which a user can sumply go:

  help.default_pager=None

at the Python prompt and have unpaged output from there on.

>I think that would make it easier to test help(). Thoughts?

Yes it would. I'm +1 _provided_ the user can set a global to tune the default 
mode, as otherwise it burdens the user with saying:

  help(foo, stdout.write)   # or "print" ?

whenever they want help. Not helpful!

Let me recite one of my favourite rules of thumb:

  If it can't be turned off, it's not a feature. - Karl Heuer

Cheers,
Cameron Simpson <cs@zip.com.au>

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

What should Python apps do when asked to show help? Steven D'Aprano <steve@pearwood.info> - 2016-04-29 02:33 +1000
  Re: What should Python apps do when asked to show help? alister <alister.ware@ntlworld.com> - 2016-04-28 16:45 +0000
    RE: What should Python apps do when asked to show help? Dan Strohl <D.Strohl@F5.com> - 2016-04-28 17:02 +0000
    Re: What should Python apps do when asked to show help? John Wong <gokoproject@gmail.com> - 2016-04-28 13:05 -0400
    RE: What should Python apps do when asked to show help? Dan Strohl <D.Strohl@F5.com> - 2016-04-28 17:25 +0000
    Re: What should Python apps do when asked to show help? Ethan Furman <ethan@stoneleaf.us> - 2016-04-28 10:27 -0700
  Re: What should Python apps do when asked to show help? Ethan Furman <ethan@stoneleaf.us> - 2016-04-28 09:49 -0700
  Re: What should Python apps do when asked to show help? Chris Angelico <rosuav@gmail.com> - 2016-04-29 03:06 +1000
  Re: What should Python apps do when asked to show help? Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2016-04-28 19:08 +0200
    Re: What should Python apps do when asked to show help? Marko Rauhamaa <marko@pacujo.net> - 2016-04-28 20:31 +0300
      Re: What should Python apps do when asked to show help? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-04-29 18:04 +1200
    RE: What should Python apps do when asked to show help? Dan Strohl <D.Strohl@F5.com> - 2016-04-28 17:32 +0000
  Re: What should Python apps do when asked to show help? Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-04-28 20:30 +0300
  Re: What should Python apps do when asked to show help? Random832 <random832@fastmail.com> - 2016-04-28 13:30 -0400
  Re: What should Python apps do when asked to show help? Grant Edwards <grant.b.edwards@gmail.com> - 2016-04-28 17:33 +0000
  RE: What should Python apps do when asked to show help? Dan Strohl <D.Strohl@F5.com> - 2016-04-28 17:39 +0000
  Re: What should Python apps do when asked to show help? Random832 <random832@fastmail.com> - 2016-04-28 13:40 -0400
  Re: What should Python apps do when asked to show help? Grant Edwards <grant.b.edwards@gmail.com> - 2016-04-28 18:14 +0000
    Re: What should Python apps do when asked to show help? Marko Rauhamaa <marko@pacujo.net> - 2016-04-28 21:31 +0300
      Re: What should Python apps do when asked to show help? Grant Edwards <grant.b.edwards@gmail.com> - 2016-04-28 19:39 +0000
      Re: What should Python apps do when asked to show help? Random832 <random832@fastmail.com> - 2016-04-28 15:51 -0400
      Re: What should Python apps do when asked to show help? Grant Edwards <grant.b.edwards@gmail.com> - 2016-04-28 21:08 +0000
        Re: What should Python apps do when asked to show help? Steven D'Aprano <steve@pearwood.info> - 2016-04-29 11:40 +1000
          manpage writing [rst, asciidoc, pod] was [Re: What should Python apps do when asked to show help?] "Martin A. Brown" <martin@linux-ip.net> - 2016-04-29 06:32 -0700
          Re: manpage writing [rst, asciidoc, pod] was [Re: What should Python apps do when asked to show help?] Ethan Furman <ethan@stoneleaf.us> - 2016-04-29 07:06 -0700
            Re: manpage writing [rst, asciidoc, pod] was [Re: What should Python apps do when asked to show help?] Rustom Mody <rustompmody@gmail.com> - 2016-04-29 08:17 -0700
          Re: manpage writing [rst, asciidoc, pod] was [Re: What should Python apps do when asked to show help?] Ben Finney <ben+python@benfinney.id.au> - 2016-04-30 12:25 +1000
            Re: manpage writing [rst, asciidoc, pod] was [Re: What should Python apps do when asked to show help?] Rustom Mody <rustompmody@gmail.com> - 2016-04-29 20:20 -0700
              Re: manpage writing [rst, asciidoc, pod] was [Re: What should Python apps do when asked to show help?] Paul Rubin <no.email@nospam.invalid> - 2016-04-29 21:06 -0700
                Re: manpage writing [rst, asciidoc, pod] was [Re: What should Python apps do when asked to show help?] Rustom Mody <rustompmody@gmail.com> - 2016-04-29 23:37 -0700
                Re: manpage writing [rst, asciidoc, pod] was [Re: What should Python apps do when asked to show help?] Paul Rubin <no.email@nospam.invalid> - 2016-04-30 00:44 -0700
          Writing manual pages using Python code (was: manpage writing) Ben Finney <ben+python@benfinney.id.au> - 2016-04-30 12:25 +1000
          Re: What should Python apps do when asked to show help? cs@zip.com.au - 2016-05-01 10:06 +1000
  Re: What should Python apps do when asked to show help? Paul Rubin <no.email@nospam.invalid> - 2016-04-28 19:15 -0700
    Re: What should Python apps do when asked to show help? Rustom Mody <rustompmody@gmail.com> - 2016-04-28 22:00 -0700
      Re: What should Python apps do when asked to show help? Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-04-29 09:02 +0300
      Re: What should Python apps do when asked to show help? Steven D'Aprano <steve@pearwood.info> - 2016-04-29 19:36 +1000
        Re: What should Python apps do when asked to show help? Rustom Mody <rustompmody@gmail.com> - 2016-04-29 02:53 -0700
          Re: What should Python apps do when asked to show help? Steven D'Aprano <steve@pearwood.info> - 2016-04-30 11:20 +1000
            Re: What should Python apps do when asked to show help? Ethan Furman <ethan@stoneleaf.us> - 2016-04-29 19:09 -0700
            Re: What should Python apps do when asked to show help? Random832 <random832@fastmail.com> - 2016-04-29 22:16 -0400
              Re: What should Python apps do when asked to show help? Rustom Mody <rustompmody@gmail.com> - 2016-04-29 19:27 -0700
                Re: What should Python apps do when asked to show help? Random832 <random832@fastmail.com> - 2016-04-29 22:36 -0400
                Re: What should Python apps do when asked to show help? Rustom Mody <rustompmody@gmail.com> - 2016-04-29 19:46 -0700
                Re: What should Python apps do when asked to show help? Random832 <random832@fastmail.com> - 2016-04-29 23:14 -0400
                Re: What should Python apps do when asked to show help? Ben Finney <ben+python@benfinney.id.au> - 2016-04-30 12:49 +1000
                Re: What should Python apps do when asked to show help? Steven D'Aprano <steve@pearwood.info> - 2016-04-30 13:23 +1000
                Re: What should Python apps do when asked to show help? Ben Finney <ben+python@benfinney.id.au> - 2016-04-30 14:06 +1000
                Re: What should Python apps do when asked to show help? Random832 <random832@fastmail.com> - 2016-04-30 00:16 -0400
                Re: What should Python apps do when asked to show help? Rustom Mody <rustompmody@gmail.com> - 2016-04-29 21:34 -0700
                Re: What should Python apps do when asked to show help? Random832 <random832@fastmail.com> - 2016-04-30 01:20 -0400
                Re: What should Python apps do when asked to show help? cs@zip.com.au - 2016-05-01 09:51 +1000
                Re: What should Python apps do when asked to show help? Steven D'Aprano <steve@pearwood.info> - 2016-05-01 14:28 +1000
                Re: What should Python apps do when asked to show help? Random832 <random832@fastmail.com> - 2016-04-30 20:41 -0400
                Re: What should Python apps do when asked to show help? Grant Edwards <grant.b.edwards@gmail.com> - 2016-05-01 02:30 +0000
                Re: What should Python apps do when asked to show help? Random832 <random832@fastmail.com> - 2016-04-30 23:46 -0400

csiph-web