Color in python's colorama not unset even with Fore.RESET

373 Views Asked by At

I use colorama to stylize the output of tqdm in a way similar to this:

tqdm.pandas(f'{Fore.CYAN}some prefix text {Fore.RESET} some text {Fore.MAGENTA} Some message')

some prefix text is cyan, and Some message is magenta, but some text is somehow red! I actually need it to be white, i.e. the general color of the console, but as you probably know Fore.WHITE is not exactly white but somewhat gray, so it won't work.

Could anybody explain how this works, why I get it red, and what can I do here? Thank you very much.

1

There are 1 best solutions below

2
L W On

My suggestion would be to use Style.RESET_ALL from the Style object instead of Fore.RESET

The solution would look like this:

from colorama import Fore, Style

tqdm.pandas(f'{Fore.CYAN}some prefix text {Style.RESET_ALL} some text {Fore.MAGENTA} Some message {Style.RESET_ALL}')