By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,525 Members | 1,648 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,525 IT Pros & Developers. It's quick & easy.

Changing TEXT color from python

P: n/a
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

Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 2005-04-04, GujuBoy <di*****@gmail.com> wrote:
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.

--
Grant Edwards grante Yow! SHHHH!! I hear SIX
at TATTOOED TRUCK-DRIVERS
visi.com tossing ENGINE BLOCKS into
empty OIL DRUMS...
Jul 18 '05 #2

P: n/a
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+Tf0bpgh6uVAMRAuTiAJ9v3DSCOVGziKW2nB2QgE Af3SIl3wCeO9LZ
jmQn1iCNFUvZIr/u1W7ByXc=
=FvM8
-----END PGP SIGNATURE-----

Jul 18 '05 #3

P: n/a
In <ma**************************************@python.o rg>, Heiko Wundram
wrote:
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.


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

Ciao,
Marc 'BlackJack' Rintsch
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.