Reading 3 bytes as an integer
python
Solution
The struct module has no option for 3-byte integers, so I think your idea of appending '\x00' is the easiest way.
In [30]: import struct
In [38]: struct.pack('>3b',0,0,1)
Out[38]: '\x00\x00\x01'
In [39]: struct.unpack('>i','\x00'+'\x00\x00\x01')
Out[39]: (1,)
Problem
How can I read 3 bytes as an integer? Does struct module provide something like that? I can read in 3 bytes and add an extra \x00 and then interpret it as a 4-byte integer, but that seems unnecessary.