raw_input with a pre-compiled data

Luca lucafbb at gmail.com
Mon Jun 22 10:19:48 CEST 2009


On Sun, Jun 21, 2009 at 12:51 PM, Peter Otten<__peter__ at web.de> wrote:
> With "traduced" you stumbled upon another false friend ;)
>
> http://it.wikipedia.org/wiki/Falso_amico

D'oh!!!   x-)

> import readline
>
> def input_default(prompt, default):
>    def startup_hook():
>        readline.insert_text(default)
>    readline.set_startup_hook(startup_hook)
>    try:
>        return raw_input(prompt)
>    finally:
>        readline.set_startup_hook(None)
>
> print input_default("directory? ", default="/home/john")
>

Thanks! It works! This is working on Linux and MacOS too.

> The readline module is specific to Unix implementations.
> I don't know what OS the OP was using.

Any one knows is this working also on Windows? I've no Win system
right no to test this...

-- 
-- luca



More information about the Python-list mailing list