Skip to content

Instantly share code, notes, and snippets.

@eyaltrabelsi
Created July 14, 2019 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eyaltrabelsi/37b24082e1fefcd22185019c817354c1 to your computer and use it in GitHub Desktop.
Save eyaltrabelsi/37b24082e1fefcd22185019c817354c1 to your computer and use it in GitHub Desktop.
Python trick Creating an iterator that filters elements from iterable returning only those for which the predicate is False
>>> import itertools
# keeping only false values
>>> list(itertools.filterfalse(bool, [None, False, 1, 0, 10]))
[None, False, 0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment