Coding for bold text

Terry Reedy tjreedy at
Wed Aug 28 19:28:14 CEST 2002

"Dan Bishop" <danb_83 at> wrote in message
news:ad052e5c.0208280121.386baef1 at
> If your system has ANSI escape sequences enabled, you can use
> def writeBold(text):
>    sys.stdout.write("\x1B[1m%s\x1B[0m" % text)
> "\x1B[1m" turns bold on and "\x1B[0m" turns it back off.

The standard Windows console window used by Python (conagent.exe) does
not have ANSI escape sequences enabled.  Nor is there any way I could
find to do so in the properties dialog (glaring omission, I think).
Does anyone know if adding something to config.sys will do so?

>>> text = 'test'
>>> print ("\x1B[1m%s\x1B[0m" % text)
On the screen, \x1B prints as a nice left arrow.

Terry J. Reedy

More information about the Python-list mailing list