The standard library functions input()
and raw_input()
don’t have this functionality. If you’re using Linux you can use the readline
module to define an input function that uses a prefill value and advanced line editing:
import readline
def rlinput(prompt, prefill=""):
readline.set_startup_hook(lambda: readline.insert_text(prefill))
try:
return input(prompt) # or raw_input in Python 2
finally:
readline.set_startup_hook()