Default/editable string to raw_input

Paraic Gallagher paraic.gallagher at gmail.com
Wed Mar 22 16:40:33 CET 2006


David Wahler wrote:

>With the disclaimer that, as others have said, this may not be the best
>user-interface choice:
>
>  import readline
>  readline.set_startup_hook(lambda: readline.insert_text(old_value))
>  try:
>    new_value = raw_input()
>  finally:
>    readline.set_startup_hook(None)
>
>Note that, among other issues, this isn't threadsafe (but then, you
>really shouldn't be doing console I/O from multiple threads anyway).
>Hope this helps.
>
>-- David
>
>  
>
Thanks David, this was exactly what I was looking for.

Paraic.





More information about the Python-list mailing list