ANSI colored output: How to determine how python was called?
Fernando PĂ©rez
fperez528 at yahoo.com
Tue May 21 12:04:16 EDT 2002
Pearu Peterson wrote:
>> colored text. And when you are trying to run colored text through pagers
>> like more/less, a whole new can of worms opens up!
>
> This can of worms is kept closed by using sys.stdout.isatty(). Try:
>
> python -c "import sys;print sys.stdout.isatty()" | less
>
Ah, but I _want_ to run colored text through a pager. And a well configured
recent version of less can do it beautifully (under linux), though 'more'
gets totally confused.
My approach has been to document it in IPython and make it an option which is
off by default. The users can test, and if it works for them they can turn it
on. When it works it's great: you get syntax highlighted source code
printouts for all your code objects from within ipython.
Cheers,
f.
More information about the Python-list
mailing list