[Python-Dev] bytes.from_hex()
M.-A. Lemburg
mal at egenix.com
Sat Feb 18 16:47:08 CET 2006
Aahz wrote:
> On Sat, Feb 18, 2006, Ron Adam wrote:
>> I like the bytes.recode() idea a lot. +1
>>
>> It seems to me it's a far more useful idea than encoding and decoding by
>> overloading and could do both and more. It has a lot of potential to be
>> an intermediate step for encoding as well as being used for many other
>> translations to byte data.
>>
>> I think I would prefer that encode and decode be just functions with
>> well defined names and arguments instead of being methods or arguments
>> to string and Unicode types.
>>
>> I'm not sure on exactly how this would work. Maybe it would need two
>> sets of encodings, ie.. decoders, and encoders. An exception would be
>> given if it wasn't found for the direction one was going in.
>
> Here's an idea I don't think I've seen before:
>
> bytes.recode(b, src_encoding, dest_encoding)
>
> This requires the user to state up-front what the source encoding is.
> One of the big problems that I see with the whole encoding mess is that
> so much of it contains implicit assumptions about the source encoding;
> this gets away from that.
You might want to look at the codecs.py module: it has all these
things and a lot more.
http://docs.python.org/lib/module-codecs.html
http://svn.python.org/view/python/trunk/Lib/codecs.py?view=markup
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Feb 18 2006)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
More information about the Python-Dev
mailing list