def supports_color():
    """
    Returns True if the running system's terminal supports color, and False
    otherwise.
    """
plat = sys.platform
supported_platform = plat != 'Pocket PC' and (plat != 'win32' or 'ANSICON' in
    os.environ)
How to detect if the console does support ANSI escape codes in Python?