def decode(lst): q = BitStream() temp = BitArray('0b0') for bit, count in lst: for i in xrange(count): temp.bool = bit q.append(temp) return q