error/warning color customization in interactive console?

Ian Clark iclark at mail.ewu.edu
Wed Jan 16 11:12:42 EST 2008


On 2008-01-16, yhvh <yhvh2000 at 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_escape_code
http://www.ioncannon.net/ruby/101/fun-with-ansi-escape-codes/

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

Ian




More information about the Python-list mailing list