title: Defining variable after assigning them value in Python 2.7
body: <p>I get this out put</p>
  
  <pre><code>=============================== RESTART: Shell ===============================
  &gt;&gt;&gt; 
  Warning (from warnings module):
    File "E:/Python/Roy Progs/test.py", line 2
      global x
  SyntaxWarning: name 'x' is assigned to before global declaration
  &gt;&gt;&gt; 
  ==================== RESTART: E:/Python/Roy Progs/test.py ====================
  10
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>when I run this code.</p>
  
  <pre><code>x=5
  global x
  x=10
  print x
  </code></pre>
  
  <p>Yes I know that defining a variable after assigning it a value is absurd, however python seems to understand the code.
  I have 2 questions:
  1) Why does Python give a warning and not an error.
  2) why is there a restart after the warning message.</p>
  
  <p>It would be helpful to know how exactly python is interpreting this code.
  thanks in advance.</p>