[Python-Dev] just say no...

Guido van Rossum guido@CNRI.Reston.VA.US
Sat, 13 Nov 1999 14:20:51 -0500


> I remember the discussion but I wasn't aware that somone had actually
> _implemented_ this:-). Part of my misunderstanding was also caused by
> the fact that I inspected what I thought would be the prime candidate
> for t#: file.write() to a non-binary file, and it doesn't use the new
> format.

I guess that's because file.write() doesn't distinguish between text
and binary files.  Maybe it should: the current implementation
together with my proposed semantics for Unicode strings would mean that
printing a unicode string (to stdout) would dump the internal encoding
to the file.  I guess it should do so only when the file is opened in
binary mode; for files opened in text mode it should use an encoding
(opening a file can specify an encoding; can we change the encoding of
an existing file?).

> I also noted a few inconsistencies at first glance, by the way: most
> modules seem to use s# for things like filenames and other
> data-that-is-readable-but-shouldn't-be-messed-with, but binascii is an 
> exception and it uses t# for uuencoded strings...

Actually, binascii seems to do it right: s# for binary data, t# for
text (uuencoded, hqx, base64).  That is, the b2a variants use s# while
the a2b variants use t#.  The only thing I'm not sure about in that
module are binascii_rledecode_hqx() and binascii_rlecode_hqx() -- I
don't understand where these stand in the complexity of binhex
en/decoding.

--Guido van Rossum (home page: http://www.python.org/~guido/)