Pastel is a simple library to help you colorize strings in your terminal.
It comes bundled with predefined styles:
info
: greencomment
: yellowquestion
: black on cyanerror
: white on red
- Use predefined styles or add you own.
- Disable colors all together by calling
with_colors(False)
. - Automatically disables colors if the output is not a TTY.
- Used in cleo.
- Supports Python 2.7+, 3.5+ and PyPy.
>>> import pastel
>>> print(pastel.colorize('<info>Information</info>'))
'Information' # Green string by default
>>> print(pastel.colorize('<fg=red;options=bold>This is bold red</>'))
'This is bold red'
pip install pastel