Python Nested Function Variable Assignment
<p>I'm trying to do something along the following lines in python3:</p>

<pre><code>i = 1337
def g():
    print(i)
    i = 42
g()
</code></pre>

<p>but get the following error</p>

<pre><code>UnboundLocalError: local variable 'i' referenced before assignment
</code></pre>

<p>I think I understand what the error message means, but why is it the case? Is there any way to circumvent this?</p>
