def look_forward(self, n=1):
        """Read ahead an item without advancing the iterator."""
        if n < 1:
            raise ValueError("'n' must be greater than 0, got %r" % n)
        required = n - len(self._prefetched)
        if required > 0:
            self._prefetched.extend(itertools.islice(self._iterator, required))
        try:
            return self._prefetched[n - 1]
        except IndexError:
            raise StopIteration from None
Read ahead an item without advancing the iterator.
recipes/Python/578560_Forward_iterator/recipe-578560.py