Why does Python let me define a variable in one scope, but use it in another?
<p>I see that it's possible to define a variable inside a scope, but then refer to it outside that scope. For instance, the following code works:</p>

<pre><code>if condition:
    x = 5
else:
    x = 10
print x
</code></pre>

<p>However, this strikes me as a bit weird. If you tried to do this in C, the variable X would not be scoped properly:</p>

<pre><code>if(condition) { int x = 5; }
else { int x = 10; }
print x; // Doesn't work: x is unavailable!
</code></pre>

<p>The solution, in C anyway, is to declare X first, THEN figure out what do to with it:</p>

<pre><code>int x;
if(condition) { x = 5; }
else { x = 10; }
print x; // Works!
</code></pre>

<p>So, in Python, my instinct is to write code like this:</p>

<pre><code>x = None
if condition:
    x = 5
else:
    x = 10
print x
</code></pre>

<p>However, I realize Python doesn't require me to do this. Any suggestions? Is there a style guideline for this scenario?</p>
