On this page
  1. itertools.filterfalse
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

itertools.filterfalse

Prev: itertools.dropwhile | Up: itertools | Next: itertools.groupby
Rel: itertools.accumulate, itertools.batched, itertools.chain, itertools.combinations
Ref: docs.python.org — itertools.filterfalse
Tags: #public #python3 #stdlib #itertools


Import

import itertools
from itertools import filterfalse

Signature & Overview

itertools.filterfalse(function, iterable, /)

Return those items of iterable for which function(item) is false.

Usage

from itertools import filterfalse

# Opposite of built-in filter(): keeps items where predicate is falsy
assert list(filterfalse(lambda x: x % 2 == 0, range(6))) == [1, 3, 5]
assert list(filterfalse(None, [0, 1, "", "ok", None])) == [0, "", None]

Gotchas

REPL Inspect

from itertools import filterfalse
help(filterfalse)

Linked from

Related notes