Ron Garret <rnospa...@flownet.com> writes: > According to what I thought I knew about unix (and I had fancied myself > a bit of an expert until just now) this is impossible. Python is > obviously picking up a different default encoding when its output is > being piped to a file, but I always thought one of the fundamental > invariants of unix processes was that there's no way for a process to > know what's on the other end of its stdout.
It certainly can. If you're using GNU and a terminal that declares support for colour, examine the difference between these two: $ ls --color=auto $ ls --color=auto > foo ; cat foo > Clues appreciated. Thanks. Research ‘man 3 isatty’ for the function most commonly used to determine whether a file descriptor represents a terminal. -- \ “If you are unable to leave your room, expose yourself in the | `\ window.” —instructions in case of fire, hotel, Finland | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list