Q:

Search a list of strings with a list of substrings

I have a list of strings and currently I can search for one substring at the time:
str = ['abc', 'efg', 'xyz']   

[s for s in str if "a" in s] 

which correctly returns 
['abc']

Now let's say I have a list of substrings instead: 
subs = ['a', 'ef']

I want a command like 
[s for s in str if anyof(subs) in s] 

which should return 
['abc', 'efg']

A:

>>> s = ['abc', 'efg', 'xyz']  
>>> subs = ['a', 'ef']
>>> [x for x in s if any(sub in x for sub in subs)]
['abc', 'efg']

Don't use str as a variable name, it's a builtin.

