I\'m writing various utilities, and I\'m really liking colorized text. Nothing fancy, just using escape sequences. I\'ve created a simple class that has a pprint(msg, color) fun
RED = 31 GREEN = 32 ESCAPE = '%s[' % chr(27) RESET = '%s0m' % ESCAPE FORMAT = '1;%dm' def colorize(text, color): return ESCAPE + (FORMAT % (color, )) + text + RESET
This function will return a string that will print colorized, with the terminal automatically being reset afterwards.