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

"Martin v. Löwis" martin at v.loewis.de
Sat Feb 18 00:58:35 CET 2006


Ian Bicking wrote:
> That str.encode(unicode_encoding) implicitly decodes strings seems like
> a flaw in the unicode encodings, quite seperate from the existance of
> str.encode.  I for one really like s.encode('zlib').encode('base64') --
> and if the zlib encoding raised an error when it was passed a unicode
> object (instead of implicitly encoding the string with the ascii
> encoding) that would be fine.
> 
> The pipe-like nature of .encode and .decode works very nicely for
> certain transformations, applicable to both unicode and byte objects.
> Let's not throw the baby out with the bath water.

The way you use it, it's a matter of notation only: why
is

zlib(base64(s))

any worse? I think it's better: it doesn't use string literals to
denote function names.

If there is a point to this overgeneralized codec idea, it is
the streaming aspect: that you don't need to process all data
at once, but can feed data sequentially. Of course, you are
not using this in your example.

Regards,
Martin


More information about the Python-Dev mailing list