Python - assign value and check condition in IF statment
<p>I have this code:</p>

<pre><code>str = func(parameter)
if not str:
   do something.
</code></pre>

<p>the function <code>func()</code> return a <code>string</code> on success and <code>''</code> on failure.
The <code>do something</code> should happen only if <code>str</code> actualy contain a string.</p>

<p>Is it possible to do the assigmnt to str on the <code>IF</code> statment itself?</p>

<p>Why not try it yourself,</p>

<pre><code>if not (a = some_func()):
  do something
      ^
SyntaxError: invalid syntax
</code></pre>

<p><strong>So, no.</strong></p>

python