An iterator object that supports peeking ahead.
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.
o
with no arguments for each
call to its next
method; if the value returned is equal to
sentinel
, StopIteration
will be raised, otherwise the
value will be returned.Method | __init__ |
__init__(o, sentinel=None) |
Method | __iter__ |
Undocumented |
Method | __next__ |
Undocumented |
Method | ​_fillcache |
Cache n items. If n is 0 or None, then 1 item is cached. |
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 | ​_cache |
Undocumented |
Instance Variable | ​_iterable |
Undocumented |
Instance Variable | sentinel |
Undocumented |
sphinx.ext.napoleon.iterators.modify_iter
Parameters | |
*args:Any | Undocumented |
sphinx.ext.napoleon.iterators.modify_iter
n
items. If n
is 0 or None, then 1 item is cached.Parameters | |
n:Optional[ | Undocumented |
Determine if iterator is exhausted.
Will never raise StopIteration
.
Returns | |
bool | Undocumented |
Get the next item or n
items of the iterator.
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.n
is 0.Parameters | |
n:int | Undocumented |
Returns | |
Any | Undocumented |
Preview the next item or n
items of the iterator.
The iterator is not advanced when peek is called.
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.
Will never raise StopIteration
.
Parameters | |
n:Optional[ | Undocumented |
Returns | |
Any | Undocumented |