def __getitem__(self, index):
        """Overloads bitstring[index]"""
        if isinstance(index, slice):
            start, stop, step = index.indices(self._length)
            if start < 0:
                return BitString(0, 0)
            if step == -1:
                step = 1
                start, stop = stop, start
            if step == 1:
                length = stop - start
                bits = ((self._bits >> (self._length - stop)) %
                        (1 << length))
                return BitString(bits, length)
            else:
                return BitString([
                    self[point]
                    for point in range(start, stop, step)
                ])

        assert isinstance(index, int)

        if index >= 0:
            assert index < self._length
            return (self._bits >> (self._length - index - 1)) % 2
        else:
            assert -index <= self._length
            return (self._bits >> (-index - 1)) % 2
dataset/ETHPy150Open hosford42/xcs/xcs/_python_bitstrings.py/BitString.__getitem__/original