'Get the next item or `n` items of the iterator.
Parameters
n : int or None
The number of items to retrieve. Defaults to None.
Returns
item or list of items
The next item or `n` items of the iterator. If `n` is None, the
item itself is returned. If `n` is an int, the items will be
returned in a list. If `n` is 0, an empty list is returned.
Raises
StopIteration
Raised if the iterator is exhausted, even if `n` is 0.'

def next(self, n=None):

    self._fillcache(n)
    if (not n):
        if (self._cache[0] == self.sentinel):
            raise StopIteration
        if (n is None):
            result = self._cache.popleft()
        else:
            result = []
    else:
        if (self._cache[(n - 1)] == self.sentinel):
            raise StopIteration
        result = [self._cache.popleft() for i in range(n)]
    return result
