title: Python - iterate through list in threaded script
body: <p>I am trying to write a threaded Python script which will iterate through a list of urls and open each one in a separate thread.</p>
  
  <pre><code>from BeautifulSoup import BeautifulSoup
  from threading import Thread
  import mechanize
  
  tickers = ["aapl", "siri", "goog", "intc"]
  nextTicker = 0
  
  def quotes(i):
      br = mechanize.Browser()
      br.addheaders = [('User-agent', 'Mozilla/5.0 (Windows; U; Windows NT   6.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10')]
      r= br.open('http://finance.yahoo.com/q?s=' + tickers[nextTicker])
      html = r.read()
      soup = BeautifulSoup(html)
      price = soup.findAll('span', attrs={"id":"yfs_l10_" + tickers[nextTicker]})
      price = price[0].string
      print price
  
  for i in range(4):
      t = Thread(target=quotes, args=(i,))
      t.start()
  </code></pre>
  
  <p>I know that I need a <code>nextTicker = nextTicker + 1</code> in there so that each thread will grab a unique ticker symbol from the list named tickers but I am not sure where to put this or how to ensure that each thread is getting a unique url.</p>
  
  <p>Right now when the script runs it just grabs the index 0 item from the list for all four threads. How do I get each thread to grab the next item in the list and append it to my base url?</p>