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

M.-A. Lemburg mal at egenix.com
Wed Apr 24 09:51:31 CEST 2013


On 23.04.2013 23:37, Nick Coghlan wrote:
> On 24 Apr 2013 01:25, "M.-A. Lemburg" <mal at egenix.com> wrote:
>>
>> On 23.04.2013 17:15, Barry Warsaw wrote:
>>> On Apr 22, 2013, at 06:22 PM, Guido van Rossum wrote:
>>>
>>>>> You can ask the same question about all the other codecs.  (And that
>>>>> question has indeed been asked in the past.)
>>>>
>>>> Except for rot13. :-)
>>>
>>> The fact that you can do this instead *is* a bit odd. ;)
>>>
>>> from codecs import getencoder
>>> encoder = getencoder('rot-13')
>>> r13 = encoder('hello world')[0]
>>
>> Just as reminder: we have the general purpose
>> encode()/decode() functions in the codecs module:
>>
>> import codecs
>> r13 = codecs.encode('hello world', 'rot-13')
>>
>> These interface directly to the codec interfaces, without
>> enforcing type restrictions. The codec defines the supported
>> input and output types.
> 
> If we already have those, why aren't they documented? 

Good question. I added them in 2004 and probably just forgot
to add the documentation:

http://hg.python.org/cpython-fullhistory/rev/8ea2cb1ec598

I guess the doc-strings could be used as basis for the
documentation.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Apr 24 2013)
>>> Python Projects, Consulting and Support ...   http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ...       http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
2013-04-17: Released eGenix mx Base 3.2.6 ...     http://egenix.com/go43

::::: Try our mxODBC.Connect Python Database Interface for free ! ::::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/


More information about the Python-Dev mailing list