pack a three byte int
Gabriel Genellina
gagsl-py at yahoo.com.ar
Thu Nov 9 21:01:25 EST 2006
At Thursday 9/11/2006 22:24, p.lavarre at ieee.org wrote:
>Perhaps Python can't concisely say three-byte int ...
>
>But Python can say six-nybble hex:
>
> >>> import binascii
> >>> cdb = binascii.unhexlify('%02X%06X%02X%02X' % (0x08, 0x12345, 0x80, 0))
> >>> binascii.hexlify(cdb)
>'080123458000'
The only problem I can see is that this code is endianness-dependent;
the suggested versions using pack(">...") not. But this may not be of
concern to you.
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
More information about the Python-list
mailing list