# -*- coding: utf-8 -*-


"""
带颜色的输出
"""


class Colored(object):

    """Keep it simple, only use `red` and `green` color."""

    RED = '\033[91m'
    GREEN = '\033[92m'

    #: no color
    RESET = '\033[0m'

    def color_str(self, color, s):
        return '{}{}{}'.format(
            getattr(self, color),
            s,
            self.RESET
        )

    def red(self, s):
        return self.color_str('RED', s)

    def green(self, s):
        return self.color_str('GREEN', s)


if __name__ == '__main__':
    colored = Colored()

    msg = "hello world"
    print(colored.red(msg))
    print(colored.green(msg))

e873b780709de80f90662a72e4828127c309d0f6
<mask token>


class Colored(object):
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    def red(self, s):
        return self.color_str('RED', s)
    <mask token>


<mask token>

<mask token>


class Colored(object):
    <mask token>
    RED = '\x1b[91m'
    GREEN = '\x1b[92m'
    RESET = '\x1b[0m'

    def color_str(self, color, s):
        return '{}{}{}'.format(getattr(self, color), s, self.RESET)

    def red(self, s):
        return self.color_str('RED', s)

    def green(self, s):
        return self.color_str('GREEN', s)


<mask token>

<mask token>


class Colored(object):
    """Keep it simple, only use `red` and `green` color."""
    RED = '\x1b[91m'
    GREEN = '\x1b[92m'
    RESET = '\x1b[0m'

    def color_str(self, color, s):
        return '{}{}{}'.format(getattr(self, color), s, self.RESET)

    def red(self, s):
        return self.color_str('RED', s)

    def green(self, s):
        return self.color_str('GREEN', s)


<mask token>

<mask token>


class Colored(object):
    """Keep it simple, only use `red` and `green` color."""
    RED = '\x1b[91m'
    GREEN = '\x1b[92m'
    RESET = '\x1b[0m'

    def color_str(self, color, s):
        return '{}{}{}'.format(getattr(self, color), s, self.RESET)

    def red(self, s):
        return self.color_str('RED', s)

    def green(self, s):
        return self.color_str('GREEN', s)


if __name__ == '__main__':
    colored = Colored()
    msg = 'hello world'
    print(colored.red(msg))
    print(colored.green(msg))

# -*- coding: utf-8 -*-


"""
带颜色的输出
"""


class Colored(object):

    """Keep it simple, only use `red` and `green` color."""

    RED = '\033[91m'
    GREEN = '\033[92m'

    #: no color
    RESET = '\033[0m'

    def color_str(self, color, s):
        return '{}{}{}'.format(
            getattr(self, color),
            s,
            self.RESET
        )

    def red(self, s):
        return self.color_str('RED', s)

    def green(self, s):
        return self.color_str('GREEN', s)


if __name__ == '__main__':
    colored = Colored()

    msg = "hello world"
    print(colored.red(msg))
    print(colored.green(msg))
