Missing codecs in Python 3.0

Carl Banks pavlovevidence at gmail.com
Tue Jun 2 22:59:06 EDT 2009

On Jun 2, 7:35 pm, Chris Rebert <c... at rebertia.com> wrote:
> On Tue, Jun 2, 2009 at 7:15 PM, samwyse <samw... at gmail.com> wrote:
> > I have a Python 2.6 program (a code generator, actually) that tries
> > several methods of compressing a string and chooses the most compact.
> > It then writes out something like this:
> >  { encoding='bz2_codec', data = '...'}
> > I'm having two problems converting this to Py3.  First is the absence
> > of the bz2_codec, among others.  It was very convenient for my program
> > to delay selection of the decoding method until run-time and then have
> > an easy way to load the appropriate code.  Is this gone forever from
> > the standard libraries?
> That appears to be the case. "bz2" is not listed onhttp://docs.python.org/3.0/library/codecs.html, but it is listed on
> the counterpart 2.6 doc page.
> You can always use the `bz2` module instead. Or write your own
> encoder/decoder for bz2 and register it with the `codecs` module.

IIRC, they decided the codecs would only be used for bytes<->unicode
encodings in Python 3.0 (which was their intended use all along),
moving other mappings (like bz2) elsewhere.  Not sure where they all
went, though.

It was convenient, admittedly, but also confusing to throw all the
other codecs in with Unicode codecs.

Carl Banks

More information about the Python-list mailing list