[Python-ideas] Struct format with multiple endianness markers

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Jul 21 23:12:41 CEST 2014


I'd like to propose a small enhancement to the
struct module: Allow the endianness characters to
occur more than once in the format string,
rather than just as the first character.

My use case is reading ESRI shapefile headers, which
mix big and little endian data. This means I can't
use a single struct.unpack call to read what is
logically a single structure, but have to split it
up and use multiple calls.

If I could switch endianness part way through
the format, I could unpack the whole structure
with a single call.

-- 
Greg


More information about the Python-ideas mailing list