[Python-Dev] Reintroduce or drop completly hex, bz2, rot13, ... codecs

Antoine Pitrou solipsis at pitrou.net
Wed Jun 9 22:26:25 CEST 2010


On Wed, 09 Jun 2010 22:13:28 +0200
"Martin v. Löwis" <martin at v.loewis.de> wrote:
> py> binascii.b2a_base64(b'foo')
> b'Zm9v\n'
> py> binascii.b2a_hex(b'foo')
> b'666f6f'
> 
> Now, I'd admit that "b2a" may be a misnomer (binary -> ASCII), but then
> it may not because ASCII actually *also* implies "bytes" (it's an encoding).
> 
> So what would you propose to change: b2a_hex should return a Unicode
> string? or this future transform method should return a Unicode string,
> whereas the module returns bytes? Something else?

Well, I would propose transform return str whereas b2a_hex returns
bytes. But I agree the consistency argument with b2a_hex looks quite
strong.
(speaking of which, the builtin hex() functions returns str, although
it's purpose is slightly different)

Regards

Antoine.


More information about the Python-Dev mailing list