Travis Griggs wrote:
I'm writing some code that does a structured read from formatted binary file.
The code I came up with looks like:
# get the first four bytes, the first gap field
chunk = byteStream.read(4)
while chunk:
# interpret the gap bytes
gap, = struct.unpack('>I', chunk)
On Tue, Oct 23, 2012 at 9:13 AM, Travis Griggs wrote:
>
> On Oct 22, 2012, at 6:33 PM, MRAB wrote:
>
>> Another way you could do it is:
>>
>> while True:
>>chunk = byteStream.read(4)
>>if not chunk:
>>break
>>...
>>
>> And you could fetch multiple signatures in one read:
>>
>>
On Oct 22, 2012, at 6:33 PM, MRAB wrote:
> By the way, in Python the recommended style for variable names (well,
> what you'd call a 'variable' in other languages :-)) is lowercase with
> underscores, e.g. "byte_stream".
We went with the
"...mixedCase is allowed only in contexts where that's
On Oct 22, 2012, at 6:33 PM, MRAB wrote:
> Another way you could do it is:
>
> while True:
>chunk = byteStream.read(4)
>if not chunk:
>break
>...
>
> And you could fetch multiple signatures in one read:
>
> signatures = list(struct.unpack('>{}I'.format(valveCount), byteStr
On 2012-10-23 01:43, Travis Griggs wrote:
I'm writing some code that does a structured read from formatted binary file.
The code I came up with looks like:
# get the first four bytes, the first gap field
chunk = byteStream.read(4)
while chunk:
# interpret the gap bytes
gap, = struct.u