base64.b64encode(data)

Chris Angelico rosuav at gmail.com
Mon Jun 13 13:07:35 EDT 2016


On Tue, Jun 14, 2016 at 1:15 AM, Michael Torrie <torriem at gmail.com> wrote:
>> Looking at this from the high-level perspective of Python, that makes it
>> conceptually bytes not text.
>
> I don't see how this is always the case.  From a high-level python
> perspective it's definitely text.  That's the whole point of base64!

Maybe what Python needs is an "ascii" type that's a subclass of both
str and bytes, and requires that the contents be <0x80. It is text, so
it can be combined with text strings; but it is also bytes, so when
you combine it with bytes strings, it'll behave as most people expect.

ChrisA



More information about the Python-list mailing list