Skip to content

Instantly share code, notes, and snippets.

@samliu
Created June 12, 2015 05:18
Show Gist options
  • Save samliu/3950823bd6ec34e9f178 to your computer and use it in GitHub Desktop.
Save samliu/3950823bd6ec34e9f178 to your computer and use it in GitHub Desktop.
class ColorPrinter(object):
"""Class to print with color."""
def __init__(self):
self.colors = {
"HEADER": '\033[95m',
"OKBLUE": '\033[94m',
"OKGREEN": '\033[92m',
"WARNING": '\033[93m',
"FAIL": '\033[91m',
"ENDC": '\033[0m',
"BOLD": '\033[1m',
"UNDERLINE": '\033[4m',
}
def println(self, text, color="NONE"):
if color in self.colors:
print self.colors[color] + text + self.colors["ENDC"]
else:
print text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment