Posted By

Glycerine on 02/22/12


Tagged

print terminal tty color coloured


Versions (?)

python terminal colour printing (termcolor)


 / Published in: Python
 

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

$ pip install termcolor;

  1. try:
  2. import termcolor
  3. from termcolor import colored
  4. except: print "No colours :("
  5.  
  6. def p(*args, **kargs):
  7. color = kargs.get('color', None)
  8.  
  9. if color and termcolor:
  10. for x in args:
  11. sys.stdout.write(colored(x, color) + '\n')
  12. else:
  13. sys.stdout.write(*args)

Report this snippet  

You need to login to post a comment.