Re: Unpack Expects the Wrong Number of Bytes

2009-07-18 Thread Ross Ridge
Timothy Crone wrote: >header = "s" >data = list(unpack(header,f.read(1))) > >however this: > >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 >form

Re: Unpack Expects the Wrong Number of Bytes

2009-07-18 Thread John Machin
On Jul 19, 12:34 am, Timothy Crone 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 the Wrong Number of Bytes

2009-07-18 Thread Timothy Crone
Hello, I have noticed that for certain format strings, struct.unpack expects the wrong number of bytes. For example, this works fine header = "4si4s4si2h2i3h4s" data = list(unpack(header,f.read(42))) however, this header = "4si4s4si2h2i3h4si" data = list(unpack(header,f.read(46))) returns the