title: UnboundLocalError: local variable "xyz" referenced before assignment
body: <p><strong>UPDATE:</strong> In response to Wooble's comment, adding a "sector = None" before the for simply returns "None". I think the issue is that the variable in the for loop is not being returned.</p>
  
  <p>The following is part of a function that was running fine, until recently, when I changed a seemingly unrelated part of the code.</p>
  
  <p><strong>#--> the only part I had changed recently was adding "stockurl" to the return statement</strong></p>
  
  <p>I now get <strong>UnboundLocalError: local variable "sector" referenced before assignment</strong>, referring to the "return" line</p>
  
  <pre><code>for sec in root.xpath(r'''//a[re:match(@href, "http://biz.yahoo.com/p/[0-9]{1}conameu.html")]''',
                  namespaces={'re': 'http://exslt.org/regular-expressions'}):
      sector = sec.text
      #print "Sector: " + sector
  
  for ind in root.xpath(r'''//a[re:match(@href, "http://biz.yahoo.com/ic/[0-9]{1,9}.html")]''',
          namespaces={'re': 'http://exslt.org/regular-expressions'}):
      industry = ind.text
      #print "Industry: " + industry
  
  #index          --&gt; don't populate here
  #followers  --&gt; don't populate here
  
  return a, b, c, d, e, f, stockurl, sector, industry
      #--&gt; the only part I had changed recently was adding "stockurl" to the function
  </code></pre>