8000 Misc cleanups and wording improvements for the itertools docs by rhettinger · Pull Request #119626 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Misc cleanups and wording improvements for the itertools docs #119626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
May 27, 2024
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
Tighen wording for islice()
  • Loading branch information
rhettinger committed May 25, 2024
commit 642e89ffa1385c8451741f02fe75f0887a8839b1
27 changes: 13 additions & 14 deletions Doc/library/itertools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -457,20 +457,19 @@ loops that truncate the stream.
.. function:: islice(iterable, stop)
islice(iterable, start, stop[, step])

Make an iterator that returns selected elements from the iterable. If *start* is
non-zero, then elements from the iterable are skipped until start is reached.
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.

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).
Make an iterator that returns selected elements from the iterable.
Works like sequence slicing but does not support negative values for
*start*, *stop*, or *step*.

If *start* is zero or ``None``, iteration starts at zero. Otherwise,
elements from the iterable are skipped until *start* is reached.

If *stop* is ``None``, iteration continues until the iterator is
exhausted, if at all. Otherwise, it stops at the specified position.

Elements are returned consecutively unless *step* is set higher than one
which results in items being skipped. If *step* is ``None``, the step
defaults to one.

Roughly equivalent to::

Expand Down
0