You can print to stdout with Python using print()
and read from stdin with input()
.
But how to programmatically print a string not only visible to the user, but editable, as if the user entered the string?
This would be helpful to ask the user about stuff while some default (or current) value is already automatically entered.
I found some questions and answers (like this one) that go in the right direction, but they are all about one application interacting with another - I want to do this in a single Python application.
E.g. a magic_input()
function:
magic_input('Country: ', val='Wonderland')
Output (where "Wonderland" would be editable by user):
Country: Wonderland