struct module...

Peter Hansen peter at
Fri Mar 21 17:17:01 CET 2003

Franck Bui-Huu wrote:
> I'm trying to read from a binary file data.
> These data have been written by a C soft using structure like
> struct xxx {
>     u1 length;
>     u1 array[length];
> }

What's a "u1"?  Is it an unsigned value of length one?  In that
case, why not just pull off the length byte first by indexing
the binary string "arrayLength = ord(arrayData[0])" and then
build the template to pass to struct() dynamically using that value?

More information about the Python-list mailing list