Baffled by readline module

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Mar 9 19:34:18 EST 2023


On 10/03/23 10:08 am, Grant Edwards wrote:
> It finally dawned on me after seeing an example I found elsewhere that
> you don't call some module method to fetch the next user-entered line.
> 
> You call the input() built-in.
> 
> Having a module modify the behavior of a built-in makes me cringe.

Importing the module is not modifying the built-in.

If your Python has been compiled with gnu readline support,
input() *already* provides recall and editing facilities.

You only need to import the readline module if you want to
change the configuration.

Yes, it would be helpful if the docs for the readline module
explained this. At present they seem to assume that you already
know what the readline module is for and just want a summary
of the API.

It *is* mentioned briefly in the docs for input(), but again
somebody wanting line editing functionality wouldn't necessarily
think of looking there.

-- 
Greg


More information about the Python-list mailing list