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


Groups > comp.lang.python > #107801 > unrolled thread

What should Python apps do when asked to show help?

Started bySteven D'Aprano <steve@pearwood.info>
First post2016-04-29 02:33 +1000
Last post2016-04-30 23:46 -0400
Articles 16 on this page of 56 — 17 participants

Back to article view | Back to comp.lang.python


Contents

  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

Page 3 of 3 — ← Prev page 1 2 [3]


#107888

FromRandom832 <random832@fastmail.com>
Date2016-04-29 22:16 -0400
Message-ID<mailman.245.1461982615.32212.python-list@python.org>
In reply to#107879
On Fri, Apr 29, 2016, at 22:09, Ethan Furman wrote:
> So I have to cripple my shell to get pydoc help to work nicely?  Neat! 
> Actually, not so much.  :(

If you don't want a pager with pydoc, when exactly do you want it?

[toc] | [prev] | [next] | [standalone]


#107890

FromRustom Mody <rustompmody@gmail.com>
Date2016-04-29 19:27 -0700
Message-ID<41ec5af0-2ffa-4202-a5df-08f9660f7c57@googlegroups.com>
In reply to#107888
On Saturday, April 30, 2016 at 7:47:11 AM UTC+5:30, Random832 wrote:
> On Fri, Apr 29, 2016, at 22:09, Ethan Furman wrote:
> > So I have to cripple my shell to get pydoc help to work nicely?  Neat! 
> > Actually, not so much.  :(
> 
> If you don't want a pager with pydoc, when exactly do you want it?

- I start a python interpreter
- ... Am pottering around for a while
- ... Need help on something... 
      [So with Steven's solution of PAGER=cat Ive to restart python!!
      Leaving that aside...]
- ... help can do one of two valid things [remember I am on a modern windowing 
      system] 
      -- start help inline, inband (cat)
      -- start help out of band (browser, yelp, etc ie some other app)
   
Instead it does some ½-assed fall-between-the-stools of both

[toc] | [prev] | [next] | [standalone]


#107893

FromRandom832 <random832@fastmail.com>
Date2016-04-29 22:36 -0400
Message-ID<mailman.249.1461983794.32212.python-list@python.org>
In reply to#107890
On Fri, Apr 29, 2016, at 22:27, Rustom Mody wrote:
> On Saturday, April 30, 2016 at 7:47:11 AM UTC+5:30, Random832 wrote:
> > On Fri, Apr 29, 2016, at 22:09, Ethan Furman wrote:
> > > So I have to cripple my shell to get pydoc help to work nicely?  Neat! 
> > > Actually, not so much.  :(
> > 
> > If you don't want a pager with pydoc, when exactly do you want it?
> 
> - I start a python interpreter
> - ... Am pottering around for a while
> - ... Need help on something... 
>       [So with Steven's solution of PAGER=cat Ive to restart python!!
>       Leaving that aside...]
> - ... help can do one of two valid things [remember I am on a modern
> windowing 
>       system] 
>       -- start help inline, inband (cat)
>       -- start help out of band (browser, yelp, etc ie some other app)
>    
> 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, why you can't just
set PAGER=cat in your profile once, now, and never see one again. How
does this "cripple your shell"; if you hate pagers so much why do you
want man or git to use one any more than pydoc?

[toc] | [prev] | [next] | [standalone]


#107896

FromRustom Mody <rustompmody@gmail.com>
Date2016-04-29 19:46 -0700
Message-ID<875ab1a2-bd23-4b1e-92ca-4079b8e86e6b@googlegroups.com>
In reply to#107893
On Saturday, April 30, 2016 at 8:06:46 AM UTC+5:30, Random832 wrote:
> On Fri, Apr 29, 2016, at 22:27, Rustom Mody wrote:
> > On Saturday, April 30, 2016 at 7:47:11 AM UTC+5:30, Random832 wrote:
> > > On Fri, Apr 29, 2016, at 22:09, Ethan Furman wrote:
> > > > So I have to cripple my shell to get pydoc help to work nicely?  Neat! 
> > > > Actually, not so much.  :(
> > > 
> > > If you don't want a pager with pydoc, when exactly do you want it?
> > 
> > - I start a python interpreter
> > - ... Am pottering around for a while
> > - ... Need help on something... 
> >       [So with Steven's solution of PAGER=cat Ive to restart python!!
> >       Leaving that aside...]
> > - ... help can do one of two valid things [remember I am on a modern
> > windowing 
> >       system] 
> >       -- start help inline, inband (cat)
> >       -- start help out of band (browser, yelp, etc ie some other app)
> >    
> > 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, why you can't just
> set PAGER=cat in your profile once, now, and never see one again. How
> does this "cripple your shell"; if you hate pagers so much why do you
> want man or git to use one any more than pydoc?

I dont get whats so hard to get in this:
When we need pagers we know where to get them
When we dont, please dont thump them on us
I dont know that anyone has taken the "I-HATE-pagers' view so much as
"Let me get them when I want them"

[toc] | [prev] | [next] | [standalone]


#107899

FromRandom832 <random832@fastmail.com>
Date2016-04-29 23:14 -0400
Message-ID<mailman.254.1461986046.32212.python-list@python.org>
In reply to#107896
On Fri, Apr 29, 2016, at 22:46, Rustom Mody wrote:
> I dont get whats so hard to get in this:
> When we need pagers we know where to get them

And if you set PAGER=cat (thus "crippling your shell"), you will
likewise know where to get them when you want to page the output from
man or git. Why is pydoc less of a "place where a pager should be used
by default" than man or git (diff, log, etc), if you accept the latter?

> When we dont, please dont thump them on us
> I dont know that anyone has taken the "I-HATE-pagers' view so much as
> "Let me get them when I want them"

Sure. And if you set PAGER=cat, then you won't ever see a pager unless
you specifically request one. Everyone wins.

[toc] | [prev] | [next] | [standalone]


#107897

FromBen Finney <ben+python@benfinney.id.au>
Date2016-04-30 12:49 +1000
Message-ID<mailman.252.1461984570.32212.python-list@python.org>
In reply to#107890
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. And, simulatenously, they want
Python's help to not use a pager at the interactive prompt.

-- 
 \        “The difference between religions and cults is determined by |
  `\                      how much real estate is owned.” —Frank Zappa |
_o__)                                                                  |
Ben Finney

[toc] | [prev] | [next] | [standalone]


#107901

FromSteven D'Aprano <steve@pearwood.info>
Date2016-04-30 13:23 +1000
Message-ID<5724253e$0$22142$c3e8da3$5496439d@news.astraweb.com>
In reply to#107897
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...

> 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.


(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 :-)


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().


pager=print would do exactly what people are asking for, and you could then
create your own wrapper to change the default:

help = functools.partial(builtins.help, pager=print)


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



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#107902

FromBen Finney <ben+python@benfinney.id.au>
Date2016-04-30 14:06 +1000
Message-ID<mailman.255.1461989175.32212.python-list@python.org>
In reply to#107901
Steven D'Aprano <steve@pearwood.info> writes:

> So they want the PAGER environment variable to specify what pager they
> want...
>
> ...so long as applications don't actually make use of that PAGER
> environment variable to determine the pager they want to use.

This at least does not baldly misrepresent the position being made :-)

-- 
 \        “My doctor told me to stop having intimate dinners for four. |
  `\               Unless there are three other people.” —Orson Welles |
_o__)                                                                  |
Ben Finney

[toc] | [prev] | [next] | [standalone]


#107904

FromRandom832 <random832@fastmail.com>
Date2016-04-30 00:16 -0400
Message-ID<mailman.256.1461989766.32212.python-list@python.org>
In reply to#107901
On Sat, Apr 30, 2016, at 00:06, Ben Finney wrote:
> Steven D'Aprano <steve@pearwood.info> writes:
> 
> > So they want the PAGER environment variable to specify what pager they
> > want...
> >
> > ...so long as applications don't actually make use of that PAGER
> > environment variable to determine the pager they want to use.
> 
> This at least does not baldly misrepresent the position being made :-)

I still don't understand how it's a misrepresentation. They said they
don't want stuff (where "stuff" includes pydoc but it's not clear why or
where it ends) to automatically use a pager without being requested, and
provided absolutely no criteria by which pydoc is special and shouldn't
behave the same as git and man do (since the entire reason PAGER=cat is
an unacceptable solution is that it "cripples" git and man).

[toc] | [prev] | [next] | [standalone]


#107905

FromRustom Mody <rustompmody@gmail.com>
Date2016-04-29 21:34 -0700
Message-ID<f6cf8d9b-adba-4c8e-9c40-43fe5013c6c1@googlegroups.com>
In reply to#107904
On Saturday, April 30, 2016 at 9:46:19 AM UTC+5:30, Random832 wrote:
> On Sat, Apr 30, 2016, at 00:06, Ben Finney wrote:
> > Steven D'Aprano  writes:
> > 
> > > So they want the PAGER environment variable to specify what pager they
> > > want...
> > >
> > > ...so long as applications don't actually make use of that PAGER
> > > environment variable to determine the pager they want to use.
> > 
> > This at least does not baldly misrepresent the position being made :-)
> 
> I still don't understand how it's a misrepresentation. They said they
> don't want stuff (where "stuff" includes pydoc but it's not clear why or
> where it ends) to automatically use a pager without being requested, and
> provided absolutely no criteria by which pydoc is special and shouldn't
> behave the same as git and man do (since the entire reason PAGER=cat is
> an unacceptable solution is that it "cripples" git and man).

Also environment variables are a nuisance and an antipattern:
http://peterlyons.com/problog/2010/02/environment-variables-considered-harmful

[toc] | [prev] | [next] | [standalone]


#107906

FromRandom832 <random832@fastmail.com>
Date2016-04-30 01:20 -0400
Message-ID<mailman.257.1461993614.32212.python-list@python.org>
In reply to#107901
On Fri, Apr 29, 2016, at 23:23, Steven D'Aprano wrote:
> Seriously, I'm thinking that a keyword argument to help might be useful:
> 
> help(object, pager=None)

I'd call it something more generic like "output".

> where:
> 
> - pager=None gives the current behaviour;
> 
> - pager="foo" calls out to the external program "foo";
> 
> - pager=callable passes the help text to callable().
> 
> 
> pager=print would do exactly what people are asking for, and you could
> then
> create your own wrapper to change the default:
> 
> help = functools.partial(builtins.help, pager=print)
> 
> 
> I think that would make it easier to test help(). Thoughts?

For testing purposes, help could return the result of the output
function, so that you can use lambda x: x to have it return the help
text.

More general thoughts: It might also be useful to move the pager
machinery from pydoc to an independent module. It's got, among other
things, a simple pager written in pure python, for use as a fallback. 

There's a lot of stuff that could be improved in the pager stuff, while
we're at it. Probably needs a single function to handle "use external
program as a pager", rather than having a bunch of logic embedded in
getpager() which only works for os.environ['PAGER'].

The "pager" function doesn't behave "properly" (in its intended behavior
of calling the expensive getpager() once when it is first called and
subsequently reusing the cached value) if a reference to it is stored
elsewhere (e.g. by importing it to another module); it should store the
cached pager function somewhere else rather than by replacing itself.

The pure-python pager only works on unix-style ttys, an analogous
function could be written for windows using msvcrt.getwch.

[toc] | [prev] | [next] | [standalone]


#107927

Fromcs@zip.com.au
Date2016-05-01 09:51 +1000
Message-ID<mailman.274.1462061343.32212.python-list@python.org>
In reply to#107901
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>

[toc] | [prev] | [next] | [standalone]


#107932

FromSteven D'Aprano <steve@pearwood.info>
Date2016-05-01 14:28 +1000
Message-ID<572585eb$0$1605$c3e8da3$5496439d@news.astraweb.com>
In reply to#107927
On Sun, 1 May 2016 09:51 am, cs@zip.com.au wrote:

> Let me recite one of my favourite rules of thumb:
> 
> If it can't be turned off, it's not a feature. - Karl Heuer


My microwave oven has a safety lock which prevents the mechanism from
operating (generating microwaves) while the door is open. Since I can't
turn it off, it is not a feature! What if I want to stick my head in the
microwave and cook it?

*wink*


Often-wanting-to-microwave-somebody-else's-head-ly y'rs,



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#107929

FromRandom832 <random832@fastmail.com>
Date2016-04-30 20:41 -0400
Message-ID<mailman.276.1462063320.32212.python-list@python.org>
In reply to#107901
On Sat, Apr 30, 2016, at 19:51, cs@zip.com.au wrote:
> _When_ they want a pager.

Why would they need an environment variable at all in that case, rather
than explicitly invoking the pager by name?

To me, *not* having PAGER=cat signifies that someone *does* want a
pager. That may be a crappy convention, but it's the one we're stuck
with.

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

But why would you not *also* want PAGER=cat in those subprocesses? You
don't want those things to spawn pagers that you haven't asked
explicitly for, either, right?

I don't get the "It's terrible if I run man or git it won't open a
pager, but I don't want pydoc to use a pager" viewpoint. It just doesn't
make any sense to me.

> Let me recite one of my favourite rules of thumb:
> 
>   If it can't be turned off, it's not a feature. - Karl Heuer

You turn it off by setting PAGER=cat. The fact that pydoc uses a pager
is the *same* feature as the fact that git and man do.

[toc] | [prev] | [next] | [standalone]


#107930

FromGrant Edwards <grant.b.edwards@gmail.com>
Date2016-05-01 02:30 +0000
Message-ID<mailman.277.1462069850.32212.python-list@python.org>
In reply to#107901
On 2016-05-01, Random832 <random832@fastmail.com> wrote:
> On Sat, Apr 30, 2016, at 19:51, cs@zip.com.au wrote:
>> _When_ they want a pager.
>
> Why would they need an environment variable at all in that case, rather
> than explicitly invoking the pager by name?

We don't want to use a PAGER variable to specify when we want a pager
and when we don't want a pager.  If we want a pager we append "| less"
to the command.  If we don't want a pager, we don't append that to the
command.

For historical reasons, "man" invokes a pager by default.  I'm not
crazy about that. If you want to argue that it's being inconsistent
then you're right: man shouldn't invoke a pager either.

-- 
Grant

[toc] | [prev] | [next] | [standalone]


#107931

FromRandom832 <random832@fastmail.com>
Date2016-04-30 23:46 -0400
Message-ID<mailman.278.1462074390.32212.python-list@python.org>
In reply to#107901
On Sat, Apr 30, 2016, at 22:30, Grant Edwards wrote:
> We don't want to use a PAGER variable to specify when we want a pager
> and when we don't want a pager.  If we want a pager we append "| less"
> to the command.  If we don't want a pager, we don't append that to the
> command.

Setting PAGER=cat - permanently, in your profile, and never ever
changing it - gives this result, yet it's described by some people here
as "So I have to cripple my shell [...]?" What is crippled? Evidently
you're not "we", since this "crippled" state of affairs seems to be a
perfectly acceptable one to you.

[toc] | [prev] | [standalone]


Page 3 of 3 — ← Prev page 1 2 [3]

Back to top | Article view | comp.lang.python


csiph-web