I have four integers {a, b, c, d} that can have the following range of values:
a - {0 or 1} (1 bit)
b - {0 or 1} (1 bit)
c - {0, 1, 2, ..., 7} (3 bits)
d - {0, 1, 2, ..., 7} (3 bits)
at first, I would like to pack them into a one byte that can be then written to a binary file.
later, I would like to unpack that one byte and get from it to a tuple of the form (a, b, c, d).
I know how to read/write a byte to a binary file in python. But how do I do the bits packing/unpacking?