Strange problem with structs Linux vs. Mac

jasonwiener jasynwiener at gmail.com
Sun Mar 16 19:22:54 CET 2008


Completely helped!  Working as expected now.

Thanks.  You really got me out of a bind!

J.

On Mar 16, 10:23 am, "Martin Blume" <mbl... at freesurf.ch> wrote:
> "jasonwiener" schrieb
>
> > I am having a VERY odd problem with unpacking right now.
> > I'm reading data from a binary file and then using a very
> > simple struct.unpack to get a long.  Works fine on my MacBook,
> > but when I push it to a Linux box,it acts differently and
> > ends up pewking.
> > [...]
>
> > the data looks to be the same, but the unpacking seems to
> > treat it differently.
>
> Probably little-endian vs. big-endian issue:
>
> >>> s
> '\x1e\xc6\xf3\xb4'
> >>> struct.unpack('<I', s)
> (3035874846L,)
> >>> struct.unpack('>I', s)
>
> (516354996L,)
>
> See help(struct) for further information.
>
> This seems to imply that the Mac, although running now on Intel
> processors, is still big-endian.
>
> HTH
> Martin




More information about the Python-list mailing list