[Python-Dev] bytes.from_hex() [Was: PEP 332 revival in coordination with pep 349?] (original) (raw)

Barry Warsaw barry at python.org
Wed Feb 15 22:42:35 CET 2006


On Wed, 2006-02-15 at 14:01 -0500, Jason Orendorff wrote:

Instead of byte literals, how about a classmethod bytes.fromhex(), which works like this:

# two equivalent things expectedmd5hash = bytes.fromhex('5c535024cac5199153e3834fe5c92e6a') expectedmd5hash = bytes([92, 83, 80, 36, 202, 197, 25, 145, 83, 227, 131, 79, 229, 201, 46, 106])

Kind of like binascii.unhexlify() but returning a bytes object.

-Barry

-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 307 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/python-dev/attachments/20060215/a7594dd8/attachment.pgp



More information about the Python-Dev mailing list