HCT added the comment:
@Victor
binascii.hexlify('abc') doesn't work in 3.4. I assume this is a new thing for
3.5
>>> import binascii
>>> binascii.hexlify('abc')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' does not support the buffer interface
>>>
>>> binascii.hexlify(b'abc')
b'616263'
@Terry
I think that space shouldn't be done by the hex function. if you allow space
between each hex, then what do you do if the bytes are actually from array of
64-bit ints? getting into support separating space for every X bytes is
probably not the scope of this.
I propose the hex functions for bytes/memoryview/bytearray should be as follow.
I prefer to not have the '0x' prefix at all, but I understand all other hex
functions adds it. would be good to have the option to not have the prefix.
bytes.hex( byte_order = sys.byteorder ) returns a hex string in small letter.
ex. c0ffee
bytes.HEX( byte_order = sys.byteorder ) returns a hex string in capital
letters. ex. DEADBEEF
bytes.from_hex( hex_str, byte_order = sys.byteorder ) returns a bytes object.
ex. b'\xFE\xFF'
another more flexible way is to have hex function accept a format similar to
how sscanf works, but this will probably bring lots of trouble for all kinds of
variants to support and the required error checks.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue9951>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com