473,386 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Coloring print lines

Hello,

Is there an easy way to make script print text with differents colors to
screen (shell)?

I mean a script that can for example print lines in red if some error occurs
in executing
some information..

--SV

----Thanks in advance.
Jul 18 '05 #1
5 20816
Sami Viitanen enlightened us with:
Is there an easy way to make script print text with differents colors to
screen (shell)?
Sure, just use ANSI codes.
I mean a script that can for example print lines in red if some
error occurs in executing some information..


Example:

print "\033[31;1mError:\033[0m some message"

Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Jul 18 '05 #2
Sami Viitanen wrote:
Hello,

Is there an easy way to make script print text with differents colors to
screen (shell)?

I mean a script that can for example print lines in red if some error occurs
in executing
some information..

--SV

----Thanks in advance.

If you're using python at X, best advice I canv give is Text-widget at
Tkinter and RTFM (sorry couldn't resist temptation :) . Otherwise you
probably have to fiddle with curses-library (unix-only).

Best way to gather information of execution is to open log-file, code
couple of monkeys and let them crack system as much as possible. This is
only my opinion. Coders are blind to their mistakes even at testing.

Jul 18 '05 #3

"Risto Peränen" <no@more.spam.plea.se> schrieb im Newsbeitrag
news:bi**********@mordred.cc.jyu.fi...
Sami Viitanen wrote:
Hello,

Is there an easy way to make script print text with differents colors to
screen (shell)?
.... If you're using python at X, best advice I canv give is Text-widget at
Tkinter and RTFM (sorry couldn't resist temptation :) . Otherwise you
probably have to fiddle with curses-library (unix-only).


Some month's ago Adam Vandenberg released some alpha curses for Windows

http://flangy.com/dev/python/curses/

I worked with my Win2000 but is only a partial implementation. It has some
color support that migth suffice for the request of the OP.

Kindly
Michael P

Jul 18 '05 #4
| Is there an easy way to make script print text
| with different colors to screen (shell)?
| ...

Sami ...

I have a couple of small examples for printing
colorized strings via Ansi escape sequences
from Python under Windows ...

http://fastq.com/~sckitching/Python/ansi_strings.zip

--
Cousin Stanley
Human Being
Phoenix, Arizona
Jul 18 '05 #5
Sami Viitanen wrote:
Hello,

Is there an easy way to make script print text with differents colors to
screen (shell)?

I mean a script that can for example print lines in red if some error occurs
in executing
some information..


IPython (http://ipython.scipy.org) supports coloring for its own purposes, and
comes with a module for this. You can simply import this module and use it for
your programs. Besides, you may like ipython itself ;)

Cheers,

f.
Jul 18 '05 #6

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

Similar topics

2
by: Wow | last post by:
Do I have to replace all new lines with \n and document.write one line? Is there something like perl's print lines print << 'body'; body in javascripts?
5
by: Tom Louchbaum | last post by:
When I preview my Access 2000 Report it looks fine. When I Email the report using DoCmd.SendObject acSendReport, "Report", acFormatRTF, "To Address", , , "Subject", , False the resulting...
6
by: Melissa | last post by:
Does anyone have a generic procedure for adding blank lines to reports like Sales details, PO details and/or Orders details. The procedure would need to count the number of line items, determine...
7
lee123
by: lee123 | last post by:
hey ( killer42 ) hi there, im programing in vb 6 and i want to make lines on a invoice i created in vb6 but don't know how i would go about doing that.. i have everything layed out to print...
4
by: ramaswamynanda | last post by:
Hello, I have an application in Access where I have developed about 10 reports. These have been working for a while and produce data properly. I recently tried exporting the report, from the...
12
by: rajash | last post by:
Thanks to everyone on this forum for their helpful comments, now here is my solution to Exercise 1.17, pretty short and neat! // print lines longer than 80 chars char x; // allocate buffer ...
3
by: lilly07 | last post by:
I am new to perl. I would like to open a file and print 2,6,10,14.. etc lines of that file content. How to do it? I amm able to open a file and print the contetnts as below: #!usr/bin/perl ...
3
by: Anja Friedrich | last post by:
Hi all, I have another question. I have an array sorted like this: small_motif_a 1853 1863 small_motif_a 1970 1980 small_motif_a 1971 1981 small_motif_b 789 799 small_motif_b 882 ...
15
by: Chocolade | last post by:
public void logger_reader(string logger_reader) { string item = @"Last"; //*** Coloring all the text inside the richTextBox1 in Red ***\\ string ftext...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.