[Python-Dev] Why does base64 return bytes?

Terry Reedy tjreedy at udel.edu
Tue Jun 14 14:17:55 EDT 2016

On 6/14/2016 12:32 PM, Toshio Kuratomi wrote:

> The input to encoding would have to remain bytes (that's the main
> purpose of base64... to turn bytes into an ascii string).

The purpose is to turn arbitrary binary data (commonly images) into 
'safe bytes' that will not get mangled on transmission (7 bit channels 
were once common) and that will not mangle a display of data transmitted 
or received.  Ignoring the EBCDIC world, which Python mostly does, the 
set of 'safe bytes' is the set that encodes printable ascii characters. 
Those bytes pass through 7 bit channels and display on ascii-based 

Terry Jan Reedy

More information about the Python-Dev mailing list