Message226730
@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. |
|
Date |
User |
Action |
Args |
2014-09-10 22:30:31 | hct | set | recipients:
+ hct, georg.brandl, rhettinger, terry.reedy, mark.dickinson, ncoghlan, pitrou, vstinner, gotgenes, christian.heimes, eric.araujo, Arfrever, wiggin15, martin.panter, serhiy.storchaka |
2014-09-10 22:30:31 | hct | set | messageid: <1410388231.07.0.0835302690733.issue9951@psf.upfronthosting.co.za> |
2014-09-10 22:30:31 | hct | link | issue9951 messages |
2014-09-10 22:30:30 | hct | create | |
|