What's the best way to replace the ternary operator in Python?
<p>If I have some code like:</p>

<pre><code>x = foo ? 1 : 2
</code></pre>

<p>How should I translate it to Python? Can I do this?</p>

<pre><code>if foo:
  x = 1
else:
  x = 2
</code></pre>

<p>Will x still be in scope outside the if / then blocks? Or do I have to do something like this?</p>

<pre><code>x = None
if foo:
  x = 1
else:
  x = 2
</code></pre>
