curses and processing terminal escape characters

mix tmmikolajczyk at gmail.com
Fri Oct 29 17:15:55 CEST 2010


Hi,

I'm wondering if there is a way in python to process a string
containing terminal escape characters. Example: Please consider the
following string:

str = ''aaaa\x1B[K\x1B[D\x1B[D\x1B[D\x1B[D\x1B[C\x1B[C\x1B[C\x1B[C
\x1B[D\x1B[D\x1B[@q\x1B[@q\x1B[@q''

as a result of printing it (print str), the console's output is as
follows:

aaqqqaa

Having such string with the escape codes I would like to call a
function that would process the input and return the "aaqqqaa" string.
Of course I'm aware that any information about colors will be missed.
I'm wondering if the curses module has such functionality.



More information about the Python-list mailing list