User input with a default value that can be modified

Etienne Hilson etienne.hilson at gmail.com
Mon May 28 14:52:11 EDT 2007


Hello the list :-)

I do a little program that permit the user to manage list of sentences.
This program runs into a linux shell.
The user can add, modify and delete the sentences.

What I want to do is :

When the user want to modify one sentence, I would like to do this :

Modify your sentence : The_sentence_appear_here_followed_by_a_cursor

And the user can go back with the cursor, like in the bash shell,
delete, modify, and when pressing enter, the new value (or the same if
not modified) is put in my variable.

Of course, the first think I did as a newbie was :

new_sentence = raw_input("Modify your sentence : "old_sentence)

But OF COURSE, stupid am I, the user cannot put the cursor back into
the old sentence !

I think about playing with some sophisticated keyboard exercise where
I could program a new input command with a value already appearing as
answer, but I am pretty sure that it exists already.

What do you think about it ?

Actually, it is quite difficult to find anything on it, because the
keywords are not very obvious (input, default answer, ...)

Thank you for your help.

Etienne
-- 
(\__/)
(='.'=)          Ceci est un petit lapin. Copiez/collez-le dans
(")_(")          votre signature pour l'aider à dominer le monde



More information about the Python-list mailing list