On 10Mar2023 23:11, Weatherby,Gerard <gweathe...@uchc.edu> wrote:
This is the implementation of cmd.Cmd (Python 3.9). As you can see in
cmdloop(), the import is already wrapped, and the readline feature can be
turned off explicitly by passing None to the completekey in the constructor.
This isn't strictly true, as I read it.
This says that if you supply a `completekey`, _then_ `cmdloop` will try
to import `readline` and set up working completion for that key.
It _doesn't_ say that readline is or is not automatically active for its
other features (command line editing, history etc).
Having a gander further down the `cmdloop` function we see:
while not stop:
if self.cmdqueue:
line = self.cmdqueue.pop(0)
else:
if self.use_rawinput:
try:
line = input(self.prompt)
except EOFError:
line = 'EOF'
and on a Python 3.10 here we see:
>>> help(input)
Help on built-in function input in module builtins:
input(prompt=None, /)
Read a string from standard input. The trailing newline is stripped.
The prompt string, if given, is printed to standard output without a
trailing newline before reading input.
If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise
EOFError.
On *nix systems, readline is used if available.
which says to me that readline is used if available, regardless of
whether it is already imported.
Cheers,
Cameron Simpson <c...@cskk.id.au>
--
https://mail.python.org/mailman/listinfo/python-list