In <[EMAIL PROTECTED]>, Chris Garland
wrote:

> But an unsigned char & a short give me this
>>>> unpack('Bh','\x90\x06\x00')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> struct.error: unpack str size does not match format

Let's pack this:

In [90]: pack('Bh', 0x90, 0x6)
Out[90]: '\x90\x00\x06\x00'

Per default the values are (un)packed with the preferred alignment of the
C compiler, so here is an extra byte to place the short at an even
address.  If you give the endianess in the format string there's no
padding:

In [91]: pack('<Bh', 0x90, 0x6)
Out[91]: '\x90\x06\x00'

Ciao,
        Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to