Yet another unicode WTF

Paul Boddie paul at boddie.org.uk
Fri Jun 5 05:11:22 EDT 2009


On 5 Jun, 03:18, Ron Garret <rNOSPA... at flownet.com> wrote:
>
> 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.

The only way to think about this (in Python 2.x, at least) is to
consider stream and file objects as things which only understand plain
byte strings. Consequently, use of the codecs module is required if
receiving/sending Unicode objects from/to streams and files.

Paul



More information about the Python-list mailing list