What should Python apps do when asked to show help?

cs at zip.com.au cs at zip.com.au
Sun May 1 18:27:12 EDT 2016


On 01May2016 21:23, Chris Angelico <rosuav at gmail.com> wrote:
>On Sun, May 1, 2016 at 8:55 PM, Steven D'Aprano <steve at pearwood.info> wrote:
>> Is there an environment variable to tell the application what you
>> consider "short", or should it read your mind?
>
>How about $LINES? If it's less than that, it'll fit on one screen. Of
>course, that still won't be perfect, but it's a definite improvement
>over guessing.

On terminal emulators you can normally query the terminal directly for its 
current size (look at the output of "stty -a" for example), and pagers do. This 
is better than $LINES, which is really a convenience thing presented by some 
shells like bash and which won't magicly change if you resize your terminal 
until bash gets another look.

If your pager can be told to autoquit if the output fits then this pain point 
(whatever your preference) can be largely obviated.

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



More information about the Python-list mailing list