[Python-Dev] Why can't I encode/decode base64 without importing a module?

Lennart Regebro regebro at gmail.com
Thu Apr 25 16:39:01 CEST 2013


On Thu, Apr 25, 2013 at 4:22 PM, MRAB <python at mrabarnett.plus.com> wrote:
> The JSON specification says that it's text. Its string literals can
> contain Unicode codepoints. It needs to be encoded to bytes for
> transmission and storage, but JSON itself is not a bytestring format.

OK, fair enough.

> base64 is a way of encoding binary data as text.

It's a way of encoding binary data using ASCII. There is a subtle but
important difference.

> In Python 3 we're trying to stop mixing binary data (bytestrings) with
> text (Unicode strings).

Yup. And that's why a byte64 encoding shouldn't return Unicode strings.

//Lennart


More information about the Python-Dev mailing list