python3 binascii.hexlify ...

Chris Angelico rosuav at gmail.com
Sat Feb 9 12:26:25 CET 2013


On Sat, Feb 9, 2013 at 10:10 PM, Peter Otten <__peter__ at web.de> wrote:
> """Return the hexadecimal representation of the binary data. Every byte of
> data is converted into the corresponding 2-digit hex representation.
> """
>
> makes it pretty clear that the function is operating on bytes, not str.

That doesn't necessarily mean it has to return bytes, though. It's
taking binary data and producing something that's plausibly either
bytes or str. It's human-readable and would definitely make sense to
be str (for instance, hex() returns a str), so imo this should be made
very clear in the docs. Maybe:

"""Return the hexadecimal representation of the binary data. Every byte of
data is converted into two bytes with the corresponding hex
representation in ASCII.
"""

or somesuch?

ChrisA



More information about the Python-list mailing list