Skip to content

FormatColor

exprint.formatter.FormatColor

FormatColor(formatter: Formatter, color: ANSIColors)

Class for coloring values.

Parameters:

Name Type Description Default

color

ANSIColors

ANSI color code

required
Source code in exprint/formatter.py
def __init__(self, formatter: Formatter, color: ANSIColors):
    super().__init__(formatter)
    self._color: str = color.value
    self._value: Format = None

RESET class-attribute instance-attribute

RESET = RESET.value

_color instance-attribute

_color: str = value

_value instance-attribute

_value: Format = None

formatter instance-attribute

formatter: Formatter = formatter

Formatter class.

value

Adds the value to the formatter.

Parameters:

Name Type Description Default

value

Format

Value to add.

required

Returns:

Type Description
FormatColor

Itself

Examples:

>>> f = Formatter()
>>> value = f.format_value().value(10.286)
>>> f.format_color(ANSIColors.BLUE).value(value)
Source code in exprint/formatter.py
def value(self, value: Format) -> FormatColor:
    """
    Adds the value to the formatter.

    Parameters
    ----------
    value : Format
        Value to add.

    Returns
    -------
    FormatColor
        Itself

    Examples
    --------

    >>> f = Formatter()
    >>> value = f.format_value().value(10.286)
    >>> f.format_color(ANSIColors.BLUE).value(value)
    """
    self._value = value
    return self