Closed GoogleCodeExporter closed 9 years ago
Hi, I'm not sure I understand the format you're suggesting, is it this:
uintbe:16[bytes:8] : read 16 bits and interpret as an unsigned big-endian
integer. Then read that many 8 byte bitstrings.
(The 'bytes' tokens reads in bytes not bits, so I suspect you may have meant
'bytes:1')
If so then I think my preferred notation would be:
s.readlist('uintbe:16 = a, a*bytes:8')
This is a little bit more flexible and needs less explanation at the expense of
an added variable, and would pretty much be done if I implement issue 123.
Your composite example then becomes
uint:32=a, a*(uint:32, 2*uint:16)
but this would return a flat list... which isn't really the same thing.
Personally I think that the complexity should go to the code rather than to the
bitstring syntax - it's easier to write a loop in Python than have one implied
in an obscure markup:
def readarray(size, fmt):
return [self.readlist(fmt) for i in range(self.read(size))]
readarray('uint:32', 'uint:32, 2*uint:16')
which can be made into a simple function call if it's going to get used a lot.
So after all that I'm coming to the opinion that it's not a general enough
usage to justify the change, which in any case sounds a bit difficult!
Glad you're finding the library useful. Cheers, Scott.
Original comment by dr.scott...@gmail.com
on 6 Dec 2012 at 4:15
Original comment by dr.scott...@gmail.com
on 9 Dec 2012 at 4:06
Original issue reported on code.google.com by
edward.s...@gmail.com
on 6 Dec 2012 at 3:31