Created
July 14, 2019 15:52
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 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