Skip to content

Instantly share code, notes, and snippets.

@ddillinger
Created May 10, 2012 17:30
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 ddillinger/2654592 to your computer and use it in GitHub Desktop.
Save ddillinger/2654592 to your computer and use it in GitHub Desktop.
>>> 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