Coloured Output to the Console with Colorama
Colorama makes it easy to output in colour, as we demonstrate in our quicksort example. We supply directions here for installation on Windows.
- Download the Colorama zip file from GitHub.
- Unzip to a convenient folder.
- Change the directory of the Command Prompt to that containing setup.py for Colorama.
Type the command to install Colorama.
We typed the command C:\Python33\python.exe setup.py install.The resulting installation log on the console began with these lines:
running install running build running build_py creating build creating build\lib creating build\lib\colorama
Use this script (adapted from the developer's instructions) to test the installation.
from colorama import init, Fore, Back init() print(Fore.RED + 'some red text') print(Back.GREEN + 'and with a green background') print(Fore.RESET + Back.RESET) print('back to normal now')