3

Is there a way to, using the modules cmd or readline, get smart completion when reading an input string that only matches a specific set of values?

For instance:

read_from_list(prompt"Name:", allowed_values=["Adam", "Bert", "Cesar"])

will create prompt

Name:

If I enter

Ad

and press complete (typically via Tab-key) I get

Adam

As a bonus it shouldn't even be possible to enter a string other than Adam, Bert or Cesar together with a set of all their prefixes.

Update: In essence I want a Python 3 variant of Emacs's completing-read: https://www.gnu.org/software/emacs/manual/html_node/elisp/Minibuffer-Completion.html

xdze2
  • 3,986
  • 2
  • 12
  • 29
Nordlöw
  • 11,838
  • 10
  • 52
  • 99

0 Answers0