On Jul 19, 12:34 am, Timothy Crone <tjcr...@gmail.com> wrote: > Hello, > > I have noticed that for certain format strings, struct.unpack expects > the wrong number of bytes. [snip] > header = "si" > data = list(unpack(header,f.read(5))) > > throws > > struct.error: unpack requires a string argument of length 8 > > So unpack expects 7 additional bytes when an integer is added to the > format string. Does anyone know what is going on?
Alignment. 1 byte for the "s", 3 pad bytes to get to the next "i" boundary, 4 bytes for the "i". http://docs.python.org/library/struct.html Then Ctrl-F search for "align" Choose a prefix character whose MO matches the struct that you need to work with. Cheers, John -- http://mail.python.org/mailman/listinfo/python-list