def get_bit(bytearr, offset): """ Returns the bit at offset into a bytearray """ byte_idx = offset / 8 bit_idx = offset - (byte_idx * 8) byte = bytearr[byte_idx] bits = BitArray(byte) return bits.get_bit(bit_idx)