Can we check multiple variables against same expression in python
<p>I know we can check a variable against multiple conditions as </p>

<pre><code>if all(x &gt;= 2 for x in (A, B, C, D)):
    print A, B, C, D
</code></pre>

<p>My question is , can we do the reverse? 
can we check me or two variables against same conditions(one or two)</p>

<pre><code>null_check = (None,'','None')
if variable1 not in null_check and variable2 not in null_check:
    print (variable1, variable2)
</code></pre>

<p>can we rewrite the above code as</p>

<pre><code>if variable1 and variable2 not in null_check:
    print (variable1, variable2)
</code></pre>

<p>If yes, which one is a better practice ? </p>

<p>Thanks in advance :)</p>

<p>No you can't do that, but as a pythonic approach you can put your <code>null_check</code> items in a <code>set</code>. And check the intersection:</p>

<pre><code>null_check = {None,'','None'}
if null_check.intersection({var1, var2}): # instead of `or` or `any()` function
    # pass  
if len(null_check.intersection({var1, var2})) == 2: # instead of `and` or `all()` function
    # pass
</code></pre>

python