Created
May 10, 2012 17:30
-
-
Save ddillinger/2654592 to your computer and use it in GitHub Desktop.
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
>>> db_cluster_list = ["has foo in it", "doesn't match", "has bar in it", "also doesn't match", "also has foo in it", "nothing to see here"] | |
>>> cluster_ignore_list = ("foo", "bar") | |
>>> filter(lambda x: [y for y in cluster_ignore_list if y in x], db_cluster_list) | |
['has foo in it', 'has bar in it', 'also has foo in it'] | |
this short circuits: | |
>>> def found(x): | |
... for item in cluster_ignore_list: | |
... if item in x: | |
... return True | |
... return False | |
... | |
>>> filter(found, db_cluster_list) | |
['has foo in it', 'has bar in it', 'also has foo in it'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment