About the global keyword in python
<pre><code># coding: utf-8

def func():
    print 'x is', x
    #x = 2   #if I add this line, there will be an error, why?
    print 'Changed local x to', x
x = 50
func()
print 'Value of x is', x 
</code></pre>

<ol>
<li>I dont't add the <code>global x</code> in func funtion, but it can still find <code>x</code> is 50, why?</li>
<li>When I add the <code>x=2</code> line in the func function, there will be an error (<code>UnboundLocalError: local variable 'x' referenced before assignment</code>), why?</li>
</ol>
