Baffled by readline module

Weatherby,Gerard gweatherby at uchc.edu
Fri Mar 10 11:07:41 EST 2023


On our Linux systems, I can up-arrow to go back to prior commands and use the left and right arrows to navigate a line. The functionality may be provided internally by readline. I’ve never had to dig into it because it meets my needs out of the box.

From: Python-list <python-list-bounces+gweatherby=uchc.edu at python.org> on behalf of Grant Edwards <grant.b.edwards at gmail.com>
Date: Friday, March 10, 2023 at 9:39 AM
To: python-list at python.org <python-list at python.org>
Subject: Re: Baffled by readline module
*** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***

On 2023-03-10, Weatherby,Gerard <gweatherby at uchc.edu> wrote:

> I would say, “No, readline is not the right tool.”
>
> cmd.Cmd is: https://urldefense.com/v3/__https://docs.python.org/3/library/cmd.html__;!!Cn_UX_p3!iH9PMR4wNfv3oBLWR_W46RY8KUzLVxsA_XRv2RJk6Td_ND59EaBvcJ58-Crx2PReX-ELMx7IEMAQ1YfpIt7xmHBGs8a1$<https://urldefense.com/v3/__https:/docs.python.org/3/library/cmd.html__;!!Cn_UX_p3!iH9PMR4wNfv3oBLWR_W46RY8KUzLVxsA_XRv2RJk6Td_ND59EaBvcJ58-Crx2PReX-ELMx7IEMAQ1YfpIt7xmHBGs8a1$> . I have a
> couple of cmd.Cmd modules, one of which I use daily and the other
> weekly.

I'll have to remember that one. It doesn't really fit my current use
case, but there are others where it would work nicely.

However, cmd.Cmd does not provide command recall and
editing. According to the page above, that's provided by the readline
module:

     If the readline module is loaded, input will automatically
     inherit bash-like history-list editing (e.g. Control-P scrolls
     back to the last command, Control-N forward to the next one,
     Control-F moves the cursor to the right non-destructively,
     Control-B moves the cursor to the left non-destructively, etc.).

--
Grant
--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!iH9PMR4wNfv3oBLWR_W46RY8KUzLVxsA_XRv2RJk6Td_ND59EaBvcJ58-Crx2PReX-ELMx7IEMAQ1YfpIt7xmEU_EBpr$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!iH9PMR4wNfv3oBLWR_W46RY8KUzLVxsA_XRv2RJk6Td_ND59EaBvcJ58-Crx2PReX-ELMx7IEMAQ1YfpIt7xmEU_EBpr$>


More information about the Python-list mailing list