Printing with colors in a portable way

Rhodri James rhodri at
Fri Jul 31 01:29:50 CEST 2009

On Thu, 30 Jul 2009 23:40:37 +0100, Robert Dailey <rcdailey at>  

> Anyone know of a way to print text in Python 3.1 with colors in a
> portable way? In other words, I should be able to do something like
> this:
> print_color( "This is my text", COLOR_BLUE )
> And this should be portable (i.e. it should work on Linux, Mac,
> Windows). an xterm, over a telnet connection, via VNC...

There's no portable way of doing this in any language, since it's
up to the terminal emulator exactly what it does with what incoming
bytes.  Some respect the ANSI colour codes, some don't; that's about
all that you can say.

Rhodri James *-* Wildebeest Herder to the Masses

More information about the Python-list mailing list