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
Improve wording for compress()
  • Loading branch information
rhettinger committed May 27, 2024
commit 1f52c89c437cb55c90a163fd1a3ed37e53e2d916
9 changes: 5 additions & 4 deletions Doc/library/itertools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ The following module functions all construct and return iterators. Some provide
streams of infinite length, so they should only be accessed by functions or
loops that truncate the stream.


.. function:: accumulate(iterable[, function, *, initial=None])

Make an iterator that returns accumulated sums or accumulated
Expand Down Expand Up @@ -309,10 +310,10 @@ loops that truncate the stream.

.. function:: compress(data, selectors)

Make an iterator that filters elements from *data* returning only those that
have a corresponding element in *selectors* is true.
Stops when either the *data* or *selectors* iterables have been exhausted.
Roughly equivalent to::
Make an iterator that returns elements from *data* where the
corresponding element in *selectors* is true. Stops when either the
*data* or *selectors* iterables have been exhausted. Roughly
equivalent to::

def compress(data, selectors):
# compress('ABCDEF', [1,0,1,0,1,1]) → A C E F
Expand Down