code: def tovalue(self, fmt='Q'):
          '''
          Convert bitstring to a int/long number.
          '''
          format_size = struct.calcsize(fmt)
          if self.length() > format_size * 8:
              raise TypeError('Cannot convert to number')
          ba = self.copy()
          ba.extend((format_size * 8 - self.length()) * [0])
          return struct.unpack_from(fmt, ba.tobytes())[0f tovalue(self, fmt='Q'):
          '''
          Convert bitstring to a int/long number.
          '''
          format_size = struct.calcsize(fmt)
          if self.length() > format_size * 8:
              raise TypeError('Cannot convert to number')
          ba = self.copy()
          ba.extend((format_size * 8 - self.length()) * [0])
          return struct.unpack_from(fmt, ba.tobytes())[0]
docs: Convert bitstring to a int/long number.