chalk is a Python library for coloring text in terminal. Only a day or two ago, Painter is another library just released for same purpose.
Here is a couple of examples. First one is the basic usage:
import chalk
chalk.blue("Hello world!!")
chalk.yellow("Listen to me!!!")
chalk.red("ERROR", pipe=chalk.stderr)
chalk.magenta('This is pretty cool', opts='bold')
chalk.cyan('...more stuff', opts=('bold', 'underscore'))
Second example shows how it can work with the standard logging module:
import logging
from chalk import log
logger = logging.getLogger(__name__)
handler = log.ChalkHandler()
handler.setLevel(logging.DEBUG)
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
logger.error('Error!!!!')
logger.warning('Warning!!!!')
logger.info('Info!!!!')
logger.debug('Debug!!!!')
chalk is written by Anthony Almarza under the MIT License, currently version 0.0.3 (2014-05-02), works for both Python 2 and 3.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.