[Baypiggies] Determining 'endian-ness'

Tony Cappellini cappy2112 at gmail.com
Tue May 20 19:49:57 CEST 2008


Just an FYI and comments welcome..

For those working with cross-platform projects, or working with binary files
from platform(s) of different endian-ness ....

This is one way to determine platform endian-ness using the struct module
Not sure who the author is, but this is taken from \PythonXX\lib\wave.py

# Determine endian-ness
import struct
if struct.pack("h", 1) == "\000\001":
    big_endian = 1
else:
    big_endian = 0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20080520/614f0b04/attachment.htm>


More information about the Baypiggies mailing list