License Public Domain
Lines 17
Permissions
Owner: Stou S.
Viewable by Everyone
Editable by All Siafoo Users
Hide
Easily highlight source code for your blog with our Syntax Highlighter. Join Siafoo Now or Learn More

Python colored output Atom Feed 3

In Brief A quick list of color formatting for python output. It helps make large amount of debug / info print statements more readable... more
# 's
 1print '\033[1;30mGray like Ghost\033[1;m'
2print '\033[1;31mRed like Radish\033[1;m'
3print '\033[1;32mGreen like Grass\033[1;m'
4print '\033[1;33mYellow like Yolk\033[1;m'
5print '\033[1;34mBlue like Blood\033[1;m'
6print '\033[1;35mMagenta like Mimosa\033[1;m'
7print '\033[1;36mCyan like Caribbean\033[1;m'
8print '\033[1;37mWhite like Whipped Cream\033[1;m'
9print '\033[1;38mCrimson like Chianti\033[1;m'
10print '\033[1;41mHighlighted Red like Radish\033[1;m'
11print '\033[1;42mHighlighted Green like Grass\033[1;m'
12print '\033[1;43mHighlighted Brown like Bear\033[1;m'
13print '\033[1;44mHighlighted Blue like Blood\033[1;m'
14print '\033[1;45mHighlighted Magenta like Mimosa\033[1;m'
15print '\033[1;46mHighlighted Cyan like Caribbean\033[1;m'
16print '\033[1;47mHighlighted Gray like Ghost\033[1;m'
17print '\033[1;48mHighlighted Crimson like Chianti\033[1;m'

A quick list of color formatting for python output. It helps make large amount of debug / info print statements more readable

The output from this script is

http://www.siafoo.net/image/11

Comments

about 1 year ago (14 Jun 2013 at 01:58 AM) by sravanthi
this is working in python interpreter but not in shell..
why is it soo..?
about 1 year ago (14 Jun 2013 at 12:24 PM) by Stou S.
Not really sure what you are asking. For me this works when run as a script, in ipython and the normal python shell.
10 months ago (01 Jan 2014 at 02:33 PM) by screwloose
Is there a chance you are using it in Bash?
As in the following echo statement...
echo '\033[1;33mFoo\033[1;m'
if so use -e to enable interpretation of escaped characters
result:
echo -e '\033[1;33mFoo\033[1;m'
10 months ago (01 Jan 2014 at 02:47 PM) by screwloose
Also "[1;" = bold "[0;" = normal