iteration over non-sequence ,how can I resolve it?

Serge Orlov Serge.Orlov at gmail.com
Mon May 29 00:42:52 EDT 2006


python wrote:
> To BJörn Lindqvist :
>  thank you . how to write the code specifically ?Could you give a
> example?

Use Queue module:

import threading
from Queue import Queue

class PrintThread(threading.Thread):
  def __init__(self, urlList, results_queue):
    threading.Thread.__init__(self)
    urllist=[]
    self.urllist=urlList
    self.results_queue = results_queue
  def run(self):
    urllink=[self.urllist] * 2
    self.results_queue.put(urllink)

results = Queue()
threadList = []
for i in range(0,2):
    thread=PrintThread("Thread"+str(i), results)
    threadList.append(thread)
    thread.start()

for i in threadList:
    linkReturned = results.get()
    for j in linkReturned:
        print j




More information about the Python-list mailing list