Skip to content

gh-102105 Fix wording in filterfalse/quantify/filter #102189

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 2 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ are always available. They are listed here in alphabetical order.
.. function:: filter(function, iterable)

Construct an iterator from those elements of *iterable* for which *function*
returns true. *iterable* may be either a sequence, a container which
is true. *iterable* may be either a sequence, a container which
supports iteration, or an iterator. If *function* is ``None``, the identity
function is assumed, that is, all elements of *iterable* that are false are
removed.
Expand All @@ -634,7 +634,7 @@ are always available. They are listed here in alphabetical order.
``None``.

See :func:`itertools.filterfalse` for the complementary function that returns
elements of *iterable* for which *function* returns false.
elements of *iterable* for which *function* is false.


.. class:: float(x=0.0)
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/itertools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ loops that truncate the stream.
.. function:: filterfalse(predicate, iterable)

Make an iterator that filters elements from iterable returning only those for
which the predicate is ``False``. If *predicate* is ``None``, return the items
which the predicate is false. If *predicate* is ``None``, return the items
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False is also correct here; this change seems to be pedantic churn only, and has no real value, IMO. I'd keep the current text. The following sentence uses None; I don't see any reason not to use False here. I'd consider leaving this as it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, False explicitly means the Python object False, no other false objects. So that's incorrect here. The None case is different.

that are false. Roughly equivalent to::

def filterfalse(predicate, iterable):
Expand Down Expand Up @@ -831,7 +831,7 @@ which incur interpreter overhead.
return next(g, True) and not next(g, False)

def quantify(iterable, pred=bool):
"Count how many times the predicate is true"
"Count how many times the predicate is True"
return sum(map(pred, iterable))

def ncycles(iterable, n):
Expand Down