Important

This documentation covers IPython versions 6.0 and higher. Beginning with version 6.0, IPython stopped supporting compatibility with Python versions lower than 3.3 including all versions of Python 2.7.

If you are looking for an IPython version compatible with Python 2.7, please use the IPython 5.x LTS release and refer to its documentation (LTS is the long term support release).

Module: utils.coloransi

Tools for coloring text in ANSI terminals.

5 Classes

class IPython.utils.coloransi.TermColors

Bases: object

Color escape sequences.

This class defines the escape sequences for all the standard (ANSI?) colors in terminals. Also defines a NoColor escape which is just the null string, suitable for defining ‘dummy’ color schemes in terminals which get confused by color escapes.

This class should be used as a mixin for building color schemes.

class IPython.utils.coloransi.InputTermColors

Bases: object

Color escape sequences for input prompts.

This class is similar to TermColors, but the escapes are wrapped in 001 and 002 so that readline can properly know the length of each line and can wrap lines accordingly. Use this class for any colored text which needs to be used in input prompts, such as in calls to raw_input().

This class defines the escape sequences for all the standard (ANSI?) colors in terminals. Also defines a NoColor escape which is just the null string, suitable for defining ‘dummy’ color schemes in terminals which get confused by color escapes.

This class should be used as a mixin for building color schemes.

class IPython.utils.coloransi.NoColors

Bases: object

This defines all the same names as the colour classes, but maps them to empty strings, so it can easily be substituted to turn off colours.

class IPython.utils.coloransi.ColorScheme(_ColorScheme__scheme_name_, colordict=None, **colormap)

Bases: object

Generic color scheme class. Just a name and a Struct.

__init__(_ColorScheme__scheme_name_, colordict=None, **colormap)
copy(name=None)

Return a full copy of the object, optionally renaming it.

class IPython.utils.coloransi.ColorSchemeTable(scheme_list=None, default_scheme='')

Bases: dict

General class to handle tables of color schemes.

It’s basically a dict of color schemes with a couple of shorthand attributes and some convenient methods.

active_scheme_name -> obvious active_colors -> actual color table of the active scheme

__init__(scheme_list=None, default_scheme='')

Create a table of color schemes.

The table can be created empty and manually filled or it can be created with a list of valid color schemes AND the specification for the default active scheme.

add_scheme(new_scheme)

Add a new color scheme to the table.

copy()

Return full copy of object

set_active_scheme(scheme, case_sensitive=<object object>)

Set the currently active scheme.

Names are by default compared in a case-insensitive way, but this can be changed by setting the parameter case_sensitive to true.

1 Function

IPython.utils.coloransi.make_color_table(in_class)

Build a set of color attributes in a class.

Helper function for building the TermColors and :class`InputTermColors`.