class documentation

An iterator object that supports peeking ahead. Parameters ---------- o : iterable or callable `o` is interpreted very differently depending on the presence of `sentinel`. If `sentinel` is not given, then `o` must be a collection object which supports either the iteration protocol or the sequence protocol. If `sentinel` is given, then `o` must be a callable object. sentinel : any value, optional If given, the iterator will call `o` with no arguments for each call to its `next` method; if the value returned is equal to `sentinel`, :exc:`StopIteration` will be raised, otherwise the value will be returned. See Also -------- `peek_iter` can operate as a drop in replacement for the built-in `iter <https://docs.python.org/3/library/functions.html#iter>`_ function. Attributes ---------- sentinel The value used to indicate the iterator is exhausted. If `sentinel` was not given when the `peek_iter` was instantiated, then it will be set to a new object instance: ``object()``.

Method __init__ __init__(o, sentinel=None)
Method __iter__ Undocumented
Method __next__ Undocumented
Method has_next Determine if iterator is exhausted.
Method next Get the next item or `n` items of the iterator.
Method peek Preview the next item or `n` items of the iterator.
Instance Variable sentinel Undocumented
Method _fillcache Cache `n` items. If `n` is 0 or None, then 1 item is cached.
Instance Variable _cache Undocumented
Instance Variable _iterable Undocumented
def __init__(self, *args): (source)

__init__(o, sentinel=None)

Parameters
*args:AnyUndocumented
def __iter__(self): (source)

Undocumented

Returns
peek_iterUndocumented
def __next__(self, n=None): (source)

Undocumented

Parameters
n:int|NoneUndocumented
Returns
AnyUndocumented
def has_next(self): (source)

Determine if iterator is exhausted. Returns ------- bool True if iterator has more items, False otherwise. Note ---- Will never raise :exc:`StopIteration`.

Returns
boolUndocumented
def next(self, n=None): (source)

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.

Parameters
n:int|NoneUndocumented
Returns
AnyUndocumented
def peek(self, n=None): (source)

Preview the next item or `n` items of the iterator. The iterator is not advanced when peek is called. 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. If the iterator is exhausted, `peek_iter.sentinel` is returned, or placed as the last item in the returned list. Note ---- Will never raise :exc:`StopIteration`.

Parameters
n:int|NoneUndocumented
Returns
AnyUndocumented
sentinel = (source)

Undocumented

def _fillcache(self, n): (source)

Cache `n` items. If `n` is 0 or None, then 1 item is cached.

Parameters
n:int|NoneUndocumented

Undocumented