I have a bitstream, of 0s and 1s obviously. It can be represented as anything (because this is Python!) but for simplicity's sake let's say it's a string.
bitStream = "1010110110110101"
Now I need to write this bitstream to a file, however if I do something along the lines of:
f.write(bitStream)
this will take up 16 bytes, obviously one byte per character, yet this is a bitstream and there are 8 bits to a byte etc. so this could really take up just two bytes. So my question then is, how do I write a series of 0s and 1s to a binary file where 8 0s and 1s would take up one byte as they are treated as bits, not chars or ints, and still be able to yield from said file the bitstream when the file is read. Is this even possible in python?