79597293

Date: 2025-04-28 21:12:35
Score: 1
Natty:
Report link

If you want a fully featured terminal interface, curses is the way to go: https://docs.python.org/3/library/curses.html

For this, though, readline is pretty good: https://docs.python.org/3/library/readline.html

It should be noted that, despite being in the standard library, it might not be available on some windows python installs. (python's readline module not available for windows?)

import readline

def setup(text):
    readline.insert_text(text)
    readline.redisplay()

readline.set_pre_input_hook(lambda: setup("DEFAULT"))
a = input("Type your input here: ")

print(f"\n\"{a}\"\n")

readline.set_pre_input_hook(lambda: setup("OTHER DEFAULT"))
a = input("Type your input here: ")

print(f"\n\"{a}\"")
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Robert Boerwinkle