from functools import reduce
a.append(1)
a.append(0)
a.append(0)
a.append(0)
a.append(1)
a.append(1)
a.append(1)
a.append(1)
print(reduce(lambda m, n: (m << 1) + n, a, 0))
Python Bitstream implementations