Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

553
Visualizações
How can I change the default pager for Python's help() debugger command?

I'm currently doing some work in a server (Ubuntu) without admin rights nor contact with the administrator. When using the help(command) in the python command line I get an error.

Here's an example:

>>> help(someCommand) 
/bin/sh: most: command not found

So, this error indicates that most pager is not currently installed. However, the server I'm working on has "more" and "less" pagers installed. So, how can I change the default pager configuration for this python utility?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

This one is annoyingly difficult to research, but I think I found it.

The built-in help generates its messages using the standard library pydoc module (the module is also intended to be usable as a standalone script). In that documentation, we find:

When printing output to the console, pydoc attempts to paginate the output for easier reading. If the PAGER environment variable is set, pydoc will use its value as a pagination program.

So, presumably, that's been set to most on your system. Assuming it won't break anything else on your system, just unset or change it. (It still pages without a value set - even on Windows. I assume it has a built-in fallback.)

over 4 years ago · Santiago Trujillo Relatório

0

You can make a custom most script that just invokes less (or even more).

The steps would be:

  1. Set up a script called most, the contents of which are:
    #!/bin/sh
    less ${@:1}  # wierdess is just "all arguments except argument 0"
  1. Put that script in a location that is on your PATH

Then most filename should just run less on that file, and that command should get called from in your python interpreter.

To be honest though, I'd just use Karl's approach.

over 4 years ago · Santiago Trujillo Relatório

0

You can view the various pager options in the source code. That function can be replaced to return whatever is desired. For example:

import pydoc

pydoc.getpager = lambda: lambda text: pydoc.pipepager(text, 'less')
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda