[Python-Dev] Printing and __unicode__
Martin v. Loewis
13 Nov 2002 21:23:36 +0100
Guido van Rossum <email@example.com> writes:
> Though it acts somewhat as if its default encoding is "ascii". This
> is somewhat inconsistent: you can write arbitrary Unicode strings, but
> the Unicode won't be converted to ASCII. ASCII is converted to
> Unicode though.
It is the only case of a "pure Unicode" stream in Python, where the
underlying "native" sequence is not one of bytes, but one of Unicode
The real problem is that the "orientation" (wide or narrow strings) is
determined by the things written into the stream.
It might be more reasonable to have StringIO.ByteIO and
StringIO.UnicodeIO constructors, which both accept an encoding=
argument, and will convert objects of the wrong "orientation"
using that encoding (defaulting to the system encoding).