Asking the user a question and giving him a default answer he can edit

Michael Hudson mwh at
Sun Jul 31 14:42:44 EDT 2005

"levander" <levander at> writes:

> Basically, I've got a bunch of questions to ask a user, the vast
> majority of which, the answer will only vary by the last few
> characters. What I'd like to do is every time the user is asked a
> question, give him the default answer as just whatever he answered last
> time. But, I want him to be able to edit this default answer.  And, the
> editted answer is what I want to operate on inside my program.

Something like this?

/>> def f():
|..  readline.set_startup_hook(lambda :readline.insert_text('aaa'))
|..  return raw_input()

> Basically, I want to the user a line editor, with a default value
> already populated.

Or you could use my pyrepl package (see google for that).


  In case you're not a computer person, I should probably point out
  that "Real Soon Now" is a technical term meaning "sometime before
  the heat-death of the universe, maybe".
                                     -- Scott Fahlman <sef at>

More information about the Python-list mailing list