[Tutor] display text in colors
chiselchip at earthlink.net
Mon Jan 1 22:16:34 CET 2007
Oh!...sorry. My OS is Mandrake 10.1.
Coupla other little 'minor' details I sorta left out. I had attempted to echo a random string on my command line by surrounding it with [again] the same color-code that works on my CLI prompt line ($PS1). That was the color coding I had tried to inject into a likely(?) spot in my code script. i.e., I have sort of approached this is a shell (rather than Python) issue, by trying to invoke an OS command (from inside my script) that-maybe-otherwise works.
BTW, I couldn't get anything to work on the command line either:
... at myprompt$ >>echo \[\e[31;1m\]"See if this goes to color red?"\[\e\0m\]
>From: Luke Paireepinart <rabidpoobear at gmail.com>
>Sent: Jan 1, 2007 2:55 PM
>To: LandSurveyor <chiselchip at earthlink.net>
>Cc: tutor at python.org
>Subject: Re: [Tutor] display text in colors
>> I would like to direct a python script to display 'print' strings in various (chosen) colors; for example:
>> print \
>> color this line blue # in the printout display-be it screen or hardcopy
>> color this line green # in the printout display-be it screen or hardcopy
>> what I tried doing was:
>> import os
>> then the line...<os.system('\[\e[31;1m\]')> just before the print command (I borrowed this formatting from my $PS1 format.
>> Nadda. Didn't work. What might I try?
>Uh, I think it's pretty important what operating system you're using here.
>Could you let us know before we try to help further?
More information about the Tutor