I have a simple Python script that uses ANSI escape sequences to have colored output on the terminal.
And this works great, but when the output is being used elsewhere (for example in VIM) all the ANSI sequences show up and it makes it really unreadable.
For example, to display RED I do something like:
^[[91m Errors:
-------^[[0m
Which is perfectly readable in the terminal.
I could add a flag to my Python command line tool to avoid displaying these characters when I need to deal with output, but I was wondering if there is a way of having colored output without messing up output.
The solution would have to use the Python Stdlib or would have to avoid installing a third party library.
However, I am perfectly OK if the approach doesn't work on Windows :)