[Python-Dev] Add transform() and untranform() methods
mal at egenix.com
Fri Nov 15 13:28:05 CET 2013
On 15.11.2013 12:45, Nick Coghlan wrote:
> On 15 November 2013 20:33, Antoine Pitrou <solipsis at pitrou.net> wrote:
>> On Fri, 15 Nov 2013 21:28:35 +1100
>> Steven D'Aprano <steve at pearwood.info> wrote:
>>> One benefit is:
>>> import codecs
>>> codec = get_name_of_compression_codec()
>>> result = codecs.encode(data, codec)
>> That's a good point.
>>> If encoding/decoding is intended to be completely generic (even if 99%
>>> of the uses will be with strings and bytes), is there any reason to
>>> prefer built-in functions rather than methods on object?
>> Practicality beats purity. Personally, I've never used codecs on
>> anything else than str and bytes objects.
> The reason I'm now putting some effort into better documenting the
> status quo for codec handling in Python 3 and filing off some of the
> rough edges (rather than proposing adding any new APIs to Python 3.x)
> is because the users I care about in this matter are web developers
> that already make use of the binary codecs and are adopting the
> single-source approach to handle supporting both Python 2 and Python
> 3. Armin Ronacher is the one who's been most vocal about the problem,
> but he's definitely not alone.
You can add me to that list :-). Esp. the hex codec is very handy.
Google returns a few thousand hits for that codec alone.
One detail that people often tend to forget is the extensibility
of the codec system. It is easily possible to add new codecs
to the system to e.g. perform encoding, escaping, compression or
other conversion operations, so the set of codecs in the stdlib
is not the complete set of codecs used in the wild - and it's
not intended to be.
As example: We've written codecs for customers that perform
special types of XML un/escaping.
Professional Python Services directly from the Source (#1, Nov 15 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-11-19: Python Meeting Duesseldorf ... 4 days to go
::::: 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
More information about the Python-Dev