[IPython-user] terminal colour howto request.
Tue Dec 9 04:02:37 CST 2008
It does help, thanks Matt.
Some context: I'm printing output from the engines I have, with different
colours. Obvious, I guess but I'm still learning......
Matt Foster wrote:
> On Mon, Dec 8, 2008 at 11:55 AM, mark starnes
> <email@example.com> wrote:
>> Hi everyone,
>> Embarrassed to ask this as I'm sure it's detailed in a manual somewhere
>> (but I can't find it!) but....
>> How can I write to the terminal in colour? I've looked through some of
>> the IPython code but couldn't spot the info I needed. I tried importing
>> curses; I don't seem to have it installed, and IPython is using colour
>> so I imagine there is another way.
>> A short example would be appreciated!
>> Best regards,
> Hi Mark,
> Your question prompted me to poke around the source, and I found
> IPython.ColorANSI. Here's an example that print the available colours:
> from IPython.ColorANSI import TermColors
> colors = TermColors()
> print 'IPython Colors:'
> for color in dir(colors):
> if not color.startswith('_'):
> print getattr(colors, color), color
> print colors.Blue, 'blue', colors.Red, 'green'
> I hope this helps,
More information about the IPython-user