Newbie: raw_input and other input methods

Carel Fellinger cfelling at iae.nl
Thu Nov 25 18:09:32 EST 1999


Hassan Aurag <aurag at geocities.com> wrote:

> Anyway, I used raw_input to be able to use readline and its nifty back 
> arrow, up arrow...

> However when I wanted to have a nifty prompt like the following one:

> raw_input("\033[0;34mInput: \033[0m"), I was surprised it got all 
> screwed up.

bash copes with this, so I dived into the source. And low and behold
there it is: bash uses the readline special codes RL_PROMPT_START_IGNORE
(='\001') and RL_PROMPT_END_IGNORE (='\002') to tell readline to 'ignore'
the chars in between.  Using this info you can get what you want:)

e.g.
>>>raw_input('\001\033[0:34m\002Input: \001\033[0m\002')

works like a charm, atleast here on my linux box




-- 
groetjes, carel




More information about the Python-list mailing list