[Python-Dev] bytes.from_hex()
Greg Ewing
greg.ewing at canterbury.ac.nz
Tue Feb 21 10:57:31 CET 2006
Stephen J. Turnbull wrote:
> What I advocate for Python is to require that the standard base64
> codec be defined only on bytes, and always produce bytes.
I don't understand that. It seems quite clear to me that
base64 encoding (in the general sense of encoding, not the
unicode sense) takes binary data (bytes) and produces characters.
That's the whole point of base64 -- so you can send arbitrary
data over a channel that is only capable of dealing with
characters.
So in Py3k the correct usage would be
base64 unicode
encode encode(x)
original bytes --------> unicode ---------> bytes for transmission
<-------- <---------
base64 unicode
decode decode(x)
where x is whatever unicode encoding the transmission
channel uses for characters (probably ascii or an ascii
superset, but not necessarily).
So, however it's spelled, the typing is such that
base64_encode(bytes) --> unicode
and
base64_decode(unicode) --> bytes
--
Greg
More information about the Python-Dev
mailing list