Printing with colors in a portable way

Aahz aahz at pythoncraft.com
Mon Aug 3 04:52:14 CEST 2009


In article <33e19169-19b4-497a-b262-2bcf7b5637d5 at r38g2000yqn.googlegroups.com>,
Robert Dailey  <rcdailey at gmail.com> wrote:
>
>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).

Much as I hate to say, use a cross-platform GUI -- Tkinter comes with
Python, and you can also use SDL via PyGame, wxWindows, pyQT, PyOpenGL,
and so on.  If that's not an option, you should have said "command-line
program".  ;-)
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"...string iteration isn't about treating strings as sequences of strings, 
it's about treating strings as sequences of characters.  The fact that
characters are also strings is the reason we have problems, but characters 
are strings for other good reasons."  --Aahz



More information about the Python-list mailing list