[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

error/warning color customization in interactive console?

will

1/16/2008 1:44:00 AM

Is it possible to output error messages in a different color?
I'm using Terminal on Gnome.
3 Answers

Ian Clark

1/16/2008 4:13:00 PM

0

On 2008-01-16, yhvh <yhvh2000@googlemail.com> wrote:
> Is it possible to output error messages in a different color?
> I'm using Terminal on Gnome.

>>> print "\033[1;31mHello\033[0m There!"

Some reading:
http://en.wikipedia.org/wiki/ANSI_e...
http://www.ioncannon.net/ruby/101/fun-with-ansi-esc...

Also, you might look at sys.excepthook to colorize an uncaught exception,
and PYTHONSTARTUP to load code automagically before an interactive
session.

Ian

Zentrader

1/16/2008 8:50:00 PM

0

On Jan 15, 5:44 pm, yhvh <yhvh2...@googlemail.com> wrote:
> Is it possible to output error messages in a different color?
> I'm using Terminal on Gnome.

For the few times that I want to do this, this simple form works with
xterm.
for j in range(1,10):
os.system("tput setaf "+str(j))
print "test for ", j

will

3/10/2008 5:02:00 PM

0

I've just discovered ipython - An Enhanced Interactive Python, which
among other things colorizes output including error codes