How to return False when using issubset and an empty set
<p>When I have two sets e.g.</p>

<pre><code>s1 = set()    
s2 = set(['somestring'])
</code></pre>

<p>and I do </p>

<pre><code>print s1.issubset(s2)
</code></pre>

<p>it returns <code>True</code>; so apparently, an empty set is always a subset of another set.</p>

<p>For my analysis, it should actually return <code>False</code> and I am wondering about the best way to do this. I can write a function like this:</p>

<pre><code>def check_set(s1, s2):
    if s1 and s1.issubset(s2):
        return True
    return False
</code></pre>

<p>which then indeed returns <code>False</code> for the example above. Is there any better way of doing this?</p>

<p>Why not just return the value? That way, you avoid having to write <code>return True</code> or <code>return False</code>.</p>

<pre><code>def check_set(s1, s2):
    return bool(s1 and s1.issubset(s2))
</code></pre>

python optimization set