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

Barry Warsaw barry at python.org
Tue Apr 23 17:07:25 CEST 2013


On Apr 22, 2013, at 10:30 PM, Donald Stufft wrote:

>I may be dull, but it wasn't until I started using Python 3 that it really
>clicked in my head what encode/decode did exactly. In Python2 I just sort of
>sprinkled one or the other when there was errors until the pain stopped. I
>mostly attribute this to str.decode and bytes.encode not existing.

This is a key observation.  It's also now much easier to *explain* what's
going on and recommend correct code in Python 3, so overall it's a win.

That's not to downplay the inconvenience of not being able to easily do
bytes->bytes or str->str transformations as easily as was possible in Python
2.  I've not thought about it much, but placing those types of transformations
on a different set of functions (methods or builtins) seems like the right
direction.  IOW, don't mess with encode/decode.

-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130423/c7d4be10/attachment.pgp>


More information about the Python-Dev mailing list