473,491 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Changing TEXT color from python

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
3 12789
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6636
by: Hank | last post by:
Hi, does anyone know how to change the foreground color of the command prompt through python? For example if i was printing out an error message, I would like it to be red where the normal...
5
4546
by: Fuzzyman | last post by:
Sorry if my terminology is wrong..... but I'm having intermittent problems dealing with accented characters in python. (Only from the 8 bit latin-1 character set I think..) I've written an...
12
1610
by: Eli Daniel | last post by:
Hi, I'm new to Python. Can you please tell me if the following is possible. My users are using other scripting launguage to write scripts. They are used to write somthing like (keeping it...
4
3724
by: GujuBoy | last post by:
i have a ansi.py file that i use in LINUX to change the text color to STDOUT when i use the "print" function...but when i move this ansi.py file over the windows...it does not work is there a...
7
6573
by: kah | last post by:
How do I change a line in a file?? For example I have the follwing text in my file: line1 line2 line3 line4 How do I replace 'line2' with 'newline'. Since the write operation in
3
1114
by: Danny | last post by:
Hello again, I am now trying to make something to change some "encrypted" text into some plain text, here is the code I have so far: text = '@7704@7002@7075@7704' // some text num = '213654'...
4
1823
by: andychambers2002 | last post by:
I'm working on a "TempFile" class that stores the data in memory until it gets larger than a specified threshold (as per PEP 42). Whilst trying to implement it, I've come across some strange...
6
1707
by: PipedreamerGrey | last post by:
I'm using the script below (originally from http://effbot.org, given to me here) to open all of the text files in a directory and its subdirectories and combine them into one Rich text file...
8
2848
by: flyingisfun1217 | last post by:
Hey, Sorry to bother everybody again, but this group seems to have quite a few knowledgeable people perusing it. Here's my most recent problem: For a small project I am doing, I need to...
3
2480
by: tedpottel | last post by:
Hi, I'm trying to write a ftp in python to send files to my webserverr. Curtly I will change the directory to the folder name, down load the file, then do a chnag dir ..\ to go back to the root...
0
7115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7190
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4881
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.