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

R. David Murray rdmurray at bitdance.com
Tue Apr 23 03:07:49 CEST 2013

On Tue, 23 Apr 2013 11:16:20 +1200, Greg Ewing <greg.ewing at canterbury.ac.nz> 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"?

You transform *into* the encoding, and untransform *out* of the encoding.
Do you have an example where that would be ambiguous?

> 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?

You can ask the same question about all the other codecs.  (And that
question has indeed been asked in the past.)

(One answer is that they used to work in Python2...but the longer we go
without restoring the functionality to Python3, the weaker that particular
argument becomes.)


More information about the Python-Dev mailing list