I would say, “No, readline is not the right tool.” cmd.Cmd is: https://docs.python.org/3/library/cmd.html. I have a couple of cmd.Cmd modules, one of which I use daily and the other weekly.
From: Python-list <python-list-bounces+gweatherby=uchc....@python.org> on behalf of Grant Edwards <grant.b.edwa...@gmail.com> Date: Thursday, March 9, 2023 at 2:29 PM To: python-list@python.org <python-list@python.org> Subject: Baffled by readline module *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** In an interactive command-line Python program on Linux, I want to be able to read a line at a time from stdin, providing command line history and editing to the user. In C, I would use GNU readline to do that. Python has the readline module, which appears to be a wrapper for GNU readline. However, I've read and re-read the documenation for that module, but I'm completely baffled. There's all sorts of stuff about history files, but I neither need nor want a history file. Likewise tab-completion: don't want it. All the examples not only involve history files and tab-completion but they're somehow connected to the interactive Python REPL, which is also completely off-base for my use case. Is the readline module not the right tool for an interactive Linux command-line application that needs to provide command line recall and editing to the user who's entering stuff on stdin from a tty? -- https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!iMrZQmCvzTBhFnzmb4Px34UNZrxSWMjU1Hxvg9CTc_-3tFWtjxB3-OrQUrXChOoNP8vm3em2V1XxihY0742KUNLDJnrV$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!iMrZQmCvzTBhFnzmb4Px34UNZrxSWMjU1Hxvg9CTc_-3tFWtjxB3-OrQUrXChOoNP8vm3em2V1XxihY0742KUNLDJnrV$> -- https://mail.python.org/mailman/listinfo/python-list