[Python-Dev] Why does base64 return bytes? (original) (raw)
Terry Reedy tjreedy at udel.edu
Tue Jun 14 14:42:36 EDT 2016
- Previous message (by thread): [Python-Dev] Why does base64 return bytes?
- Next message (by thread): [Python-Dev] Why does base64 return bytes?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 6/14/2016 12:29 PM, Mark Lawrence via Python-Dev wrote:
As I've the time to play detective I'd suggest https://mail.python.org/pipermail/python-3000/2007-July/008975.html
Thank you for finding that. I reread it and still believe that bytes was the right choice. Base64 is an generic edge encoding for binary data. It fits in with the the standard paradigm as a edge encoding.
Receive encoded bytes. Decode bytes to python objects Manipulate python objects Encode python objects to bytes Send bytes.
Receive and send can be from and to either local files or sockets usually connected to remote systems. Transmissions can have blocks with different encodings. In the latter case, the bytes need to be parsed into blocks with different encodings.
In the (fairly common) special case that a transmission consists entirely of text in 1 encoding (ignoring any transmission wrappers), decode and encode can be incorporated into a text-mode file object. If a transmission consists entirely or partly of binary, one can open in binary mode and .write one or more blocks of encoded bytes, possible with encoding data.
-- Terry Jan Reedy
- Previous message (by thread): [Python-Dev] Why does base64 return bytes?
- Next message (by thread): [Python-Dev] Why does base64 return bytes?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]