are set of strings all substrings of another set
<p>I have many sets of strings and wish to test them against sets of substrings. I wish to identify which sets contain all of the substrings.</p>

<pre><code>set1 = {'A123', 'B234', 'C345'}
set2 = {'A123', 'F234', 'H345'}
substring_set1 = {'A', 'B'}
</code></pre>

<p>So something like this in pseudocode:</p>

<pre><code>all(substring_set1.areSubstrings(set1))
True

all(substring_set1.areSubstrings(set2)
False
</code></pre>

<p>Or something like this maybe?</p>

<pre><code>if all(x in v for v in set1 for x in substring_set1):
    do stuff
</code></pre>

<p>I guess I could go about it with an array of for loops, but I feel there probably is a cleaner way of doing this. Any suggestions? Thanks!</p>

<p>The following approach looks clean enough to me:</p>

<pre><code>&gt;&gt;&gt; all(any(x in v for v in set1) for x in substring_set1)
True
&gt;&gt;&gt; all(any(x in v for v in set2) for x in substring_set1)
False
</code></pre>

python python-3.x