Automatic ANSI colors for Python scripts (static colors too).
pip install kcolorsExamples of auto-disable colors:
python main.py | cat # output into |, no colors
python main.py > data.txt # output into data.txt, no colors
python main.py # colorsAny import from kcolors enables VT Mode for the Windows terminal.
import kcolors # Not recomended, but works
import kcolors.vt # I just want vt (doesn't matter the kcolors version)from kcolors import Colors, SColors
# Color values become "" if the output target is not a terminal
print(f"The color is {Colors.RED}red{Colors.END}.")
# Static colors (will be printed always)
print(f"The color is {SColors.RED}red{SColors.END}.")They are both the same, just a set of references to Colors and SColors, but 'i' means inverted.
from kcolors.refs import * # pyright: ignore
print(f"{RED}Dynamic Color{END} - {RED_}Static Color{END}.")from kcolors.irefs import * # pyright: ignore
print(f"{RED}Static Color{END} - {RED_}Dynamic Color{END}.")