Return to Snippet

Revision: 55794
at February 22, 2012 22:24 by Glycerine


Initial Code
try:
    import termcolor
    from termcolor import colored
except: print "No colours :("

def p(*args, **kargs):
    color = kargs.get('color', None)

    if color and termcolor:
        for x in args:
            sys.stdout.write(colored(x, color) + '\n')
    else:
        sys.stdout.write(*args)

Initial URL

                                

Initial Description
Quick method for creating coloured tty in python terminal using 'termcolor'

$ pip install termcolor;

Initial Title
python terminal colour printing (termcolor)

Initial Tags
terminal, color

Initial Language
Python