title: python global variable not defined in for loop
body: <p>This code gives the error: <code>UnboundLocalError: local variable 'LINES' referenced before assignment</code> but <code>LINES</code> is clearly initialized since if I comment out the line below the print statement it throws no errors and prints  <code>len(lines) = 0</code> as expected.  Am I not understanding something about python?? Whats going on here?</p>
  
  <pre><code>LINES = []
  
  def foo():
    for prob in range(1,3):
      print "len(lines) = %d" % len(LINES)
      LINES = []
  
  if __name__ == "__main__":
    foo()
  </code></pre>