Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: python3 binascii.hexlify ...

Thread Tools

Re: python3 binascii.hexlify ...

Cameron Simpson
Posts: n/a
On 09Feb2013 22:26, Chris Angelico <(E-Mail Removed)> wrote:
| On Sat, Feb 9, 2013 at 10:10 PM, Peter Otten <(E-Mail Removed)> 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.

Well of course. I want a hexadecimal string representation of a chunk of
bytes. It should be producing a string.

| 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?

Only if returning a string would break something relying on hexlify
returning bytes. The natural way to write this function is to have it
return a string.

_If_ there's some dependency in the stdlib, maybe a doc fix would do.
But otherwise IMO the function should be returning a string.

What is the use case for returning bytes that just _look_ like a string?
It is returning a textual representation; without a good reason, that
should be a string.
Cameron Simpson <(E-Mail Removed)>

Because of its special customs, crossposting between alt.peeves and normal
newsgroups is discouraged. - Cameron Spitzer
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: is the same betweent python3 and python3.2? Andrew Berg Python 0 06-16-2012 11:11 AM
python3 - the hardest hello world ever ? Helmut Jarausch Python 23 10-24-2008 07:19 AM
python3: 'where' keyword Andrey Tatarinov Python 97 01-16-2005 12:04 PM
python and macros (again) [Was: python3: 'where' keyword] Python 37 01-14-2005 10:24 PM
Python3: on removing map, reduce, filter Andrey Tatarinov Python 18 01-11-2005 07:22 AM