But in both cases you probably want bytes ->  bytes and str ->  str. If
you want text out then put text in, if you want bytes out then put bytes in.

No, I don't think so. If I'm using hex "encoding", it's because I want
to see a text representation of some arbitrary bytestring (in order to
display it inside another piece of text, for example).
In other words, the purpose of hex is precisely to give a textual
display of non-textual data.

I think this is the way it is for consistency reasons (which I would not lightly wish away). I think you agree that base64 is a bytes->bytes
transformation (because you typically use it as a payload on some wire
protocol).

So:

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?

Regards,
Martin
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to