allenfrostline

ColorPrint: Print Colorfully in Python


2018-11-09

This is a simple print function overwritten so that you can specify different colors in Terminal outputs.

To use this feature, you’ll need to import this customized print function from the ColorPrint package, the GitHub repo is here.

from ColorPrint import print

print('Hello World!')  # default printing

print('Hello World!', 'r')  # color abbreviation
print('Hello World!', 'c')

print('Hello World!', 'red')  # color full names
print('Hello World!', 'cyan')

print('Hello World!', 'rand')  # random color
print('Hello World!', 'random')

print('Hello World!', 'discrete_random')  # random color for each character
print('Hello World!', 'drand')

and the output is as below (in Terminal):

I find this especially useful when you’re trying to focus on command-line workflow only and don’t want to build you own wheel over and over again.