On Fri, Jun 13, 2008 at 9:27 PM, Ping Zhao <[EMAIL PROTECTED]> wrote: > However, when I tried to rewrite them in short: > > header = struct.unpack('2s1i', self.__read(src, 6)) > ... > It was weired that the required argument length increased to 8.
This is an alignment issue; if you don't specify a structure format character, the struct module acts like the data is laid out in memory as a C compiler would do it. http://en.wikipedia.org/wiki/Data_structure_alignment http://docs.python.org/lib/module-struct.html Specifying little-endian byte order will force the data to be packed (unaligned), and will also make your code more portable: struct.unpack('<2s1i', ...) -Miles -- http://mail.python.org/mailman/listinfo/python-list