I have a list of strings, from which I want to locate every line that has \'http://\' in it, but does not have \'lulz\', \'lmfao\', \'.png\', or any other items in a list of str
This is almost equivalent to F.J's solution, but uses generator expressions instead of lambda expressions and the filter function:
haystack = ['http://blah', 'http://lulz', 'blah blah', 'http://lmfao']
exclude = ['lulz', 'lmfao', '.png']
http_strings = (s for s in haystack if s.startswith('http://'))
result_strings = (s for s in http_strings if not any(e in s for e in exclude))
print list(result_strings)
When I run this it prints:
['http://blah']