[Python-3000] base64 - bytes and strings (original) (raw)

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Jul 30 02:08:22 CEST 2007


Nick Coghlan wrote:

Py3k strings are unicode, so returning a string would mean you just have to encode it again using the ascii codec to get the bytes to put on the wire.

I still believe that producing a string is conceptually the right thing to do. The point of base64 is to encode binary data as text, not binary data as binary data.

If I ever had a reason to use base64, it would be because I had a "wire" that would accept text but not binary data, e.g. a file open in text mode, or some other text that I wanted to embed it in. Getting bytes in that situation would force me to make an extra conversion.

-- Greg



More information about the Python-3000 mailing list