Newbie: raw_input and other input methods

Hassan Aurag aurag at geocities.com
Wed Nov 24 20:48:14 EST 1999


 Hello,

This is my first question to this newsgroup.

I am writing a small math app using pygnome, python.

It is a terminal based app. 

I read input process and print output. It is based on a hybrid onecmd 
and InteractiveInterpreter from code.py.

I am using python 1.5.2.

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.

This is true if you run this anywhere (gnome-terminal, vt without 
X...). It won't know the real size of terminal, because it thinks 
len("\033[0;34mInput: \033[0m") = 24 instead of what is really there 
and that is 7.

This means that line wrapping won't work on your first line!

My question is:

Is there another input method a la raw_input (not like input that 
evals also) that can be mixed with readline and still sees that string 
as it is.

Or, is there any workaround?

Btw, the weird escape sequences turn prompt to blue!


Thanks in advance


H. Aurag
remove.aurag at geocities.com










More information about the Python-list mailing list