Unpacking byte strings from a file of unknown size

Mark mseagoe at gmail.com
Tue Oct 28 10:43:25 EDT 2008


Thanks I tested your solution and that works.

One of the things that didn't work was
for chunk in myfile.read(10):
    info1, info2, info3 = struct.unpack('<IIH', chunk)

It gets an error saying unpack requires a string of length 10, which I
thought chunk would be after the read(10).  I'm still a little
confused as to why.

But thanks very much Steven, for a working solution.

Mark



More information about the Python-list mailing list