Baffled by readline module

Cameron Simpson cs at cskk.id.au
Thu Mar 9 18:28:49 EST 2023


On 09Mar2023 13:08, Grant Edwards <grant.b.edwards at gmail.com> wrote:
>Having a module modify the behavior of a built-in makes me cringe.

Maybe. But input(), like print(), is one of those funky conveniences for 
human interaction. I'm somewhat ok with that. If for no other reason 
than to make keyboard arrow keys act as normal humans expect them to (as 
opposed to old nerds who predate such fancies). General improvement of 
the user experience.

Another thing affected by readline is the cmd module, which will use it 
during the input step for completion _if the module is present_.  And 
use it for the input itself if it is loaded. (These might not mean 
different things and instead be an accident of phrasing.) Again, a human 
interaction convenience and I'm good with it.

Good enough to have written this code recently:

     try:
       import readline
     except ImportError:
       pass

just to turn it on if available.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Python-list mailing list