Changing TEXT color from python

G

GujuBoy

so i am writing a program in Python and i want to print out a few
statements in Different colors

for example "Print hello world in RED, and "GOOD BYE in blue" "

how can i do this...and hopefully without including any external
modules.

thanks in advance
 
G

Grant Edwards

so i am writing a program in Python and i want to print out a few
statements in Different colors

for example "Print hello world in RED, and "GOOD BYE in blue" "

how can i do this...

Depends on what you're printing on.

tty?
curses
os.popen('tput')

printer?
reportlab
and hopefully without including any external modules.

I suppose you can pick an output device and hard-wire the
escape sequences into your code.
 
H

Heiko Wundram

Am Montag, 4. April 2005 21:59 schrieb GujuBoy:
how can i do this...and hopefully without including any external
modules.

It depends.

Under *NIX, have a look at the curses module.

Under Windows, Google for ANSI.SYS and read up on Escape Sequences, or check
out the curses for Windows implementation that's floating around somewhere on
the net, I don't know the URL.

HTH!

--
--- Heiko.
listening to: Nine Inch Nails - Somewhat Damaged
see you at: http://www.stud.mh-hannover.de/~hwundram/wordpress/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQBCUZ+Tf0bpgh6uVAMRAuTiAJ9v3DSCOVGziKW2nB2QgEAf3SIl3wCeO9LZ
jmQn1iCNFUvZIr/u1W7ByXc=
=FvM8
-----END PGP SIGNATURE-----
 
M

Marc 'BlackJack' Rintsch

Heiko Wundram said:
Am Montag, 4. April 2005 21:59 schrieb GujuBoy:

It depends.

Under *NIX, have a look at the curses module.

Under Windows, Google for ANSI.SYS and read up on Escape Sequences, or check
out the curses for Windows implementation that's floating around somewhere on
the net, I don't know the URL.

At least under Linux the ANSI color escapes should work too. Out of the
box.

Ciao,
Marc 'BlackJack' Rintsch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top