Convert a bitarray to integer in Python
There is a method in bitarray.util called ba2int:
from bitarray import bitarray
from bitarray.util import ba2int

ba = bitarray('1001')  # 9

i = ba2int(ba)

print(f'Value: {i} type: {type(i)}')
# Output: Value: 9 type: &lt;class 'int'&gt;

From the doc:

ba2int(bitarray, /, signed=False) -&gt; int
Convert the given bitarray into an integer. The bit-endianness of the
bitarray is respected. signed indicates whether two's complement is
used to represent the integer.