[Python-Dev] bytes.from_hex() [Was: PEP 332 revival in coordination with pep 349?]

Guido van Rossum guido at python.org
Wed Feb 15 22:48:16 CET 2006

On 2/15/06, M.-A. Lemburg <mal at egenix.com> wrote:
> Jason Orendorff wrote:
> > Also the pseudo-encodings ('hex', 'rot13',
> > 'zip', 'uu', etc.) generally scare me.
> Those are not pseudo-encodings, they are regular codecs.
> It's a common misunderstanding that codecs are only seen as serving
> the purpose of converting between Unicode and strings.
> The codec system is deliberately designed to be general enough
> to also work with many other types, e.g. it is easily possible to
> write a codec that convert between the hex literal sequence you
> have above to a list of ordinals:

It's fine that the codec system supports this. However it's
questionable that these encodings are invoked using the standard
encode() and decode() APIs; and it will be more questionable once
encode() returns a bytes object. Methods that return different types
depending on the value of an argument are generally a bad idea. (Hence
the movement to have separate opentext and openbinary or openbytes

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list