raw_input with a pre-compiled data
Chris Rebert
clp2 at rebertia.com
Mon Jun 22 04:36:05 EDT 2009
On Mon, Jun 22, 2009 at 1:19 AM, Luca<lucafbb at gmail.com> wrote:
> 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...
No, it won't. "specific to Unix" == Unix-only
Cheers,
Chris
--
http://blog.rebertia.com
More information about the Python-list
mailing list