[Baypiggies] Determining 'endian-ness'
Guido van Rossum
guido at python.org
Tue May 20 22:38:50 CEST 2008
sys.byteorder
On Tue, May 20, 2008 at 10:49 AM, Tony Cappellini <cappy2112 at gmail.com> wrote:
>
> 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
>
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> http://mail.python.org/mailman/listinfo/baypiggies
>
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Baypiggies
mailing list