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>You can try this, it's the shortest version I could come up with: </p>

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

python