from bitarray import bitarray
import struct
d = bitarray('0' * 30, endian='little')
d[5] = 1
print(struct.unpack('<L', d)[0])
d[6] = 1
print(struct.unpack('<L', d)[0])
How to convert bitarray to an integer in python