binary encoded hexadecimal
Martin von Loewis
loewis at informatik.hu-berlin.de
Wed Aug 23 09:42:07 EDT 2000
Kapil Thangavelu <kthangavelu at earthlink.net> writes:
> i'm trying to create a binary encoded (c struct) hexadecimal string.
> basically implementing the functionality of perl's
>
> pack('H*', $my_hexadecimal_string);
I don't know the functionality of perl's pack, but I assume you want a
function
>>> cdr.ASCII_to_octet('127623AF')
'\022v#\257'
where input bytes are grouped in pairs, understood as hexadecimal byte
representations, and the resulting bytes are put back into bytes.
This function above is from Fnorb (www.fnorb.com), where it is used to
convert IORs and the like.
I'd agree that it is generally useful enough to put it into the
standard library; I'd rather put it into binascii than into the struct
module, and I'd give it a different name than ASCII_to_octet.
Regards,
Martin
More information about the Python-list
mailing list