Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #38509

Re: python3 binascii.hexlify ...

References <20130209104433.GA13443@cskk.homeip.net> <kf5aqq$etq$1@ger.gmane.org>
Date 2013-02-09 22:26 +1100
Subject Re: python3 binascii.hexlify ...
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1540.1360409195.2939.python-list@python.org> (permalink)

Show all headers | View raw


On Sat, Feb 9, 2013 at 10:10 PM, Peter Otten <__peter__@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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: python3 binascii.hexlify ... Chris Angelico <rosuav@gmail.com> - 2013-02-09 22:26 +1100

csiph-web