What is a good pythonic way to match a list of substrings to a list of strings, like the following:
if 'sub1' in str1 or 'sub2' in str1 or ... 'subN' in str1 or\
'sub1' in str2 or 'sub2' in str2 or ... 'subN' in str2 or\
...
'sub1' in strM or 'sub2' in strM or ... 'subN' in strM:
One way is to unite them with list comprehension, like this:
strList = [str1, str2, ..., strM]
subList = ['sub1', ..., 'subN']
if any(sub in str for sub in subList for str in strList):
Is there anything better, like a library function perhaps, to absorb one of the dimensions?
Thank you very much.