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

Steven D'Aprano steve at pearwood.info
Tue Apr 23 04:04:45 CEST 2013


On 23/04/13 09:16, Greg Ewing wrote:

Victor Stinner wrote:

The last proposition is to add transform() and untransform() methods to bytes and str types. ... If I remember correctly, the missing point is how to define which types are supported by a codec Also, for any given codec, which direction is "transform" and which is "untransform"? Also also, what's so special about base64 et al that they deserve an ultra-special way of invoking them, instead of having to import a class or function like you do for every other piece of library functionality?

As others have pointed out in the past, repeatedly, the codec system is completely general and can transform bytes->bytes and text->text just as easily as bytes<->text. Or indeed any bijection, as the docs for 2.7 point out. The question isn't "What's so special about base64?" The questions should be:

If you haven't read this, you should:

http://lucumr.pocoo.org/2012/8/11/codec-confusion/

-- Steven



More information about the Python-Dev mailing list