Dennis Sweeney added the comment:
In particular, it's one ascii character:
>>> b'abracadabra'.hex('😋')
ValueError: sep must be ASCII.
I wouldn't be completely opposed to allowing longer strings, but since there
are easy enough ways to do it already, put me at a -0. We can see if anyon
arne123 added the comment:
Well, I think there are many ways to solve this in python (e.g. I used
iteration before, wasn't aware of the sep. at all), but when there is already a
separator, why limiting it to one character?
--
___
Python tracker
<
Dennis Sweeney added the comment:
Would there be substantial benefit of a new feature over using the existing
feature and then calling str.replace()?
>>> b = b'abracadabra'
>>> "0x" + b.hex(":").replace(":", ", 0x")
'0x61, 0x62, 0x72, 0x61, 0x63, 0x61, 0x64, 0x61, 0x62, 0x72, 0x61'
-
New submission from arne123 :
I use Python to support some C development.
Often I need to convert bytearrays to C like convention:
0x12, 0x34
It would be very convenient for this use case if the separator could be a
string (like ", 0x") instead of just a single character.
--
component