'Retrieves an item or slice from the set of results.'

def __getitem__(self, k):

    if (not isinstance(k, ((slice,) + six.integer_types))):
        raise TypeError
    assert (((not isinstance(k, slice)) and (k >= 0)) or (isinstance(k, slice) and ((k.start is None) or (k.start >= 0)) and ((k.stop is None) or (k.stop >= 0)))), 'Negative    indexing    is    not    supported.'
    if (self._result_cache is not None):
        if (self._iter is not None):
            if isinstance(k, slice):
                if (k.stop is not None):
                    bound = int(k.stop)
                else:
                    bound = None
            else:
                bound = (k + 1)
            if (len(self._result_cache) < bound):
                self._fill_cache((bound - len(self._result_cache)))
        return self._result_cache[k]
    if isinstance(k, slice):
        qs = self._clone()
        if (k.start is not None):
            start = int(k.start)
        else:
            start = None
        if (k.stop is not None):
            stop = int(k.stop)
        else:
            stop = None
        qs.query.set_limits(start, stop)
        return ((k.step and list(qs)[::k.step]) or qs)
    try:
        qs = self._clone()
        qs.query.set_limits(k, (k + 1))
        return list(qs)[0]
    except self.model.DoesNotExist as e:
        raise IndexError(e.args)
