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>You can do this very similarly to your first code block:</p>

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

<p>Or:</p>

<pre><code>null_check = (None,'','None')
variables = variable1, variable2 # defined elsewhere
if all(variable not in null_check for variable in variables:
    print (*variables)
</code></pre>

python