I am new to learning Python, and I came across colorama. As a test project, I wanted to print out all the available colors in colorama.
from colorama import Fore
from colorama import init as colorama_init
colorama_init(autoreset=True)
colors = [x for x in dir(Fore) if x[0] != "_"]
for color in colors:
print(color + f"{color}")
of course this outputs all black output like this:
BLACKBLACK
BLUEBLUE
CYANCYAN
...
because the Dir(Fore) just gives me a string representation of Fore.BLUE
, Fore.GREEN
, ...
Is there a way to access all the Fore Color property so they actually work, as in:
print(Fore.BLUE + "Blue")
Or in other words, this may express my problem better.
I wanted to write this:
print(Fore.BLACK + 'BLACK')
print(Fore.BLUE + 'BLUE')
print(Fore.CYAN + 'CYAN')
print(Fore.GREEN + 'GREEN')
print(Fore.LIGHTBLACK_EX + 'LIGHTBLACK_EX')
print(Fore.LIGHTBLUE_EX + 'LIGHTBLUE_EX')
print(Fore.LIGHTCYAN_EX + 'LIGHTCYAN_EX')
print(Fore.LIGHTGREEN_EX + 'LIGHTGREEN_EX')
print(Fore.LIGHTMAGENTA_EX + 'LIGHTMAGENTA_EX')
print(Fore.LIGHTRED_EX + 'LIGHTRED_EX')
print(Fore.LIGHTWHITE_EX + 'LIGHTWHITE_EX')
print(Fore.LIGHTYELLOW_EX + 'LIGHTYELLOW_EX')
print(Fore.MAGENTA + 'MAGENTA')
print(Fore.RED + 'RED')
print(Fore.RESET + 'RESET')
print(Fore.WHITE + 'WHITE')
print(Fore.YELLOW + 'YELLOW')
in a shorter way:
for color in all_the_colors_that_are_available_in_Fore:
print('the word color in the representing color')
#or something like this?
print(Fore.color + color)