Message406778
In the past this was worked around by installing a third-party module:
https://github.com/pyreadline/pyreadline
For Python 3.10, however this module doesn't work. And pyreadline doesn't seem to be maintained anymore, so it's possible it won't get fixed.
https://github.com/pyreadline/pyreadline/issues/73
Consider the following code:
import cmd
import readline
open("history.txt", "w").write("first line\nsecond line\n")
readline.clear_history()
readline.read_history_file("history.txt")
class MyShell(cmd.Cmd):
def __init__(self):
super().__init__()
shell = MyShell()
shell.cmdloop()
This works fine on MacOs Python, also on Linux and on Windows prior to 3.10 with the readline module added. It won't work going forward.
The Windows cmd implementation clearly uses readline or some compatible lib under the hood, so Python should make it available to developers. |
|
Date |
User |
Action |
Args |
2021-11-22 13:51:22 | keeely | set | recipients:
+ keeely |
2021-11-22 13:51:22 | keeely | set | messageid: <1637589082.36.0.67630471216.issue45870@roundup.psfhosted.org> |
2021-11-22 13:51:22 | keeely | link | issue45870 messages |
2021-11-22 13:51:22 | keeely | create | |
|