Yet another unicode WTF
ben+python at benfinney.id.au
Thu Jun 4 21:53:19 EDT 2009
Ron Garret <rNOSPAMon at 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 |
More information about the Python-list