It is possible to use Python's struct.unpack to extract the useful values from a Bitmap file header, as follows:
magic, file_size, _, _, data_offset = struct.unpack('<2sLHHL', file_header)
assert magic == 'BM'
Is there any way to avoid the need to assign to _
(or another throwaway variable) here? Is it possible to change the format string to make struct.unpack
skip over the two unused H
fields?