Paul Moore <p.f.mo...@gmail.com> added the comment:
This works fine for me in Windows terminal, but I see the behaviour described when using the conventional "Command prompt" window. Enabling ANSI codes is handled via SetConsoleMode (see here: https://docs.microsoft.com/en-us/windows/console/setconsolemode). The following proof of concept script correctly displays coloured text: from ctypes import * kernel32 = windll.kernel32 kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7) ansi_red = "\x1b[31m" ansi_normal = "\x1b[0m" print(ansi_red + "This is red!" + ansi_normal) Agreed this would be worthwhile setting on stdout by default. The code at https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#example-of-enabling-virtual-terminal-processing seems to be an example of how to do this while still supporting older systems ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40134> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com