.. 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.
``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)
.. 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
that are false. Roughly equivalent to::
def filterfalse(predicate, iterable):
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):