Problem with unpack hex to decimal

Fredrik Lundh fredrik at pythonware.com
Sun Apr 17 14:58:28 EDT 2005


"serpent17 at gmail.com" wrote:

> I was looking at this:
> http://docs.python.org/lib/module-struct.html
> and tried the following
> 
>>>> import struct
>>>> struct.calcsize('h')
> 2
>>>> struct.calcsize('b')
> 1
>>>> struct.calcsize('bh')
> 4
> 
> I would have expected
> 
>>>> struct.calcsize('bh')
> 3
> 
> what am I missing ?

the sentence

    "By default, C numbers are represented in the machine's native format
    and byte order, and properly aligned by skipping pad bytes if necessary
    (according to the rules used by the C compiler)."

and the text and table following that sentence.

</F>




More information about the Python-list mailing list