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