Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Break islice() docs into smaller paragraphs
  • Loading branch information
rhettinger committed Oct 18, 2022
commit b1a632a36f97a7a4901831463cac2aec5d8771f8
17 changes: 11 additions & 6 deletions Doc/library/itertools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -474,10 +474,17 @@ loops that truncate the stream.
Afterward, elements are returned consecutively unless *step* is set higher than
one which results in items being skipped. If *stop* is ``None``, then iteration
continues until the iterator is exhausted, if at all; otherwise, it stops at the
specified position. Unlike regular slicing, :func:`islice` does not support
negative values for *start*, *stop*, or *step*. Can be used to extract related
fields from data where the internal structure has been flattened (for example, a
multi-line report may list a name field on every third line). Roughly equivalent to::
specified position.

If *start* is ``None``, then iteration starts at zero. If *step* is ``None``,
then the step defaults to one.

Unlike regular slicing, :func:`islice` does not support negative values for
*start*, *stop*, or *step*. Can be used to extract related fields from
data where the internal structure has been flattened (for example, a
multi-line report may list a name field on every third line).

Roughly equivalent to::

def islice(iterable, *args):
# islice('ABCDEFG', 2) --> A B
Expand All @@ -504,8 +511,6 @@ loops that truncate the stream.
for i, element in zip(range(i + 1, stop), iterable):
pass

If *start* is ``None``, then iteration starts at zero. If *step* is ``None``,
then the step defaults to one.

.. function:: pairwise(iterable)

Expand Down