The question is in the title :)
More precisely, I use colorama to have coloured output from my script :
from colorama import init, Fore
init() # comment if running from Eclipse
print(Fore.RED + 'some red text')
I mainly use my script with 2 terminal :
the Eclipse console, more precisely the ANSI console plugin, which supports ANSI control sequences
the Windows console, which can output colors but not with ANSI control sequences.
Normally, colorama.init() determines if Windows is used and modifies the ANSI sequences so that colors are displayed correctly.
But this behaviour is not needed when executing the script from within Eclipse. In fact, colours won't display because colorama.init() enables ANSI sequences replacement (we're on Windows after all) but Eclipse console doesn't understand the Windows sequences.
How can I detect from my script that I'm running Eclipse or Windows Console ?
Typically, I'd like to do:
from colorama import init, Fore
if windows_console():
init()
print(Fore.RED + 'some red text')