Ferramenta para criar prompts mais interativos em Python.
https://python-prompt-toolkit.readthedocs.io/en/latest/
Instalação
pip install prompt_toolkit
Exemplos
Básico:
from prompt_toolkit import prompt
while 1:
user_input = prompt('>')
print(user_input)
Com histórico:
from prompt_toolkit import PromptSession
from prompt_toolkit.history import FileHistory
def main():
our_history = FileHistory(".example-history-file")
# The history needs to be passed to the `PromptSession`. It can't be passed
# to the `prompt` call because only one history can be used during a
# session.
session = PromptSession(history=our_history)
while True:
text = session.prompt("> ")
print(f"You said: {text}")
Doc com outros exemplos: https://python-prompt-toolkit.readthedocs.io/en/latest/pages/asking_for_input.html#
Referência: https://opensource.com/article/17/5/4-practical-python-libraries