Missing codecs in Python 3.0
Benjamin Peterson
benjamin at python.org
Wed Jun 3 15:16:41 EDT 2009
samwyse <samwyse <at> gmail.com> writes:
>
> 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 = '...'}
In 3.x, all codecs which don't directly map between unicode and bytestrings have
been removed.
>
> 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?
No, just use the bz2 module in the stdlib.
>
> Second, I would write my data out using the 'string_escape' codec.
Why does the repr seem less efficient?
More information about the Python-list
mailing list