473,474 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Output in color

I'm curious how I can make Python print text in color.
Jul 18 '05 #1
2 17254
Bradford Powers wrote:

I'm curious how I can make Python print text in color.


Begin by specifying the platform on which you want this to work,
and other possibly relevant details such as whether this is a
console program or one with a GUI (presumably not), and maybe
some other details I can't think of right now.

Also you might check the archives of this newsgroup at
groups.google.com. This sort of question comes up fairly
often. Might even be a FAQ at this point (see www.python.org).

-Peter
Jul 18 '05 #2
Bradford Powers wrote:
I'm curious how I can make Python print text in color.


That depends strictly on your printer. With my hp LaserJet 1200,
no way -- not even Python's power can overcome the hardware's
limitations in this regard... it's a black-and-white printer and
that's all there is to it! If I did have a color printer, then
I would have Python produce the appropriate postscript code, or
"escape-sequences" in whatever printer-specific language a given
printer requires to have it output color text (or, depending on my
operating system, printer driver, filters, etc, I might have to
send appropriate "escape-sequences" or whatever to the DRIVER in
order to convince it to drive the printer appropriately).

Much the same holds if you're using "printing" in the vague
sense in which Python itself uses it in the keyword "print"
(which I detest and consider a wart, albeit shared by such
diverse languages as Python, Perl, C, Fortran, etc): it all
depends on what device (physical hardware one, or one in some
part simulated by software) you're outputting to.

For example,

print '\033[1;31mciao!'

will set all text emitted henceforward to red _IF_ the
terminal (or emulator thereof) on which the text is being
written is ANSI compliant.
Alex

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: peter | last post by:
Hello, If I have a PhP code below in a linux+apache environment, ============================== <?php> the first php block code <?> The HTML code goes here
2
by: Samantha | last post by:
Is there a limit on the size of the file Python will read then output. I am reading a file of 433 lines and when I output the same file it only will output 421 lines. The last line is cut off also....
4
by: Ellarco | last post by:
How can I perform output (file output for the monent, possibly socket in the future) in such a way that output produced on different compiler/machines pairs is indistinguishable? Specifically my...
1
by: Michael Kragh Pedersen | last post by:
I have made an XSLT document, looking like this. <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="text"/> <xsl:template...
10
by: tram | last post by:
How do we pass on the step1 output file to step2 of the same job? I would like to know the current job's output file programmetically, instead of hard coding it. Any idaes would be appreciated. ...
3
by: Liren Zhao | last post by:
I use some "Console.WriteLine(some strings here)" to display some debug information in my winform program. How can I get the information in my programe or same them in a text file ?
4
by: Kevin Mansel via .NET 247 | last post by:
Ok, basically this is my problem. I'm building a console app tocall a dos program. So i'm using the Shell command to call theprogram, now depending on what happens, I want to read theoutput that...
2
by: Steve | last post by:
I have created a console app that simply prints out a message a couple times, then exits, here is the code: <code> for(int i = 0; i < 10; i++) { System.Threading.Thread.Sleep(500);...
24
by: kalamantina | last post by:
#include "stdafx.h" #include <stdio.h> #define output( x ) printf( #x "\r\n" );fflush( stdout ) class CMyBase { public: CMyBase() { output( CMyBase() ); f(*this);
32
by: spibou | last post by:
Is the output of the C preprocessor deterministic ? What I mean by that is , given 2 compilers which conform to the same standard, will their preprocessors produce identical output given as input...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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
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
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...
0
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.