def __getitem__(self, k):
        """
        Limited slicing support ([N] and [:N] only, for positive N)
        """
        if isinstance(k, int) and k >= 0:
            try:
                return next(itertools.islice(self.__iter__(), k, None))
            except StopIteration:
                raise IndexError(k)

        elif not isinstance(k, slice) \
                or k.start is not None \
                or k.step is not None \
                or k.stop is None \
                or k.stop <= 0:
            raise ValueError("Only query[:+N] or query[+N] slicing is supported.")

        return list(itertools.islice(self.__iter__(), k.stop))
def __getitem__ ( self , k ) : if isinstance ( k , int ) and k >= 0 : try : return next ( itertools . islice ( self . __iter__ ( ) , k , None ) ) except StopIteration : raise IndexError ( k ) elif not isinstance ( k , slice ) or k . start is not None or k . step is not None or k . stop is None or k . stop <= 0 : raise ValueError ( "Only query[:+N] or query[+N] slicing is supported." ) return list ( itertools . islice ( self . __iter__ ( ) , k . stop ) )
Limited slicing support ([N] and [:N] only, for positive N)