ANSI colored output: How to determine how python was called?
François Pinard
pinard at iro.umontreal.ca
Mon May 20 16:58:21 EDT 2002
[Donn Cave]
> Quoth Pearu Peterson <pearu at cens.ioc.ee>:
> | Are there alternative (hopefully better) ways to decide whether the
> | output "device" of python stdout supports ANSI colored text or not?
> It might be nice to pull something else out of the environment too, for
> the sake of people who are missing the boat on TERM - maybe LS_COLORS,
> which is already used by GNU ls, or something specific to your application.
The normal way to check for colour terminal support is through terminal
info capabilities (terminfo). Check for `op', 'AF', `AB', `Sf', `Sb',
'Co', `pa' and `NC' capabilities, in particular. I forgot details as of
now, but remember I had to fight a bit to get everything right.
--
François Pinard http://www.iro.umontreal.ca/~pinard
More information about the Python-list
mailing list