How to pass list to Python worker thread?

How to pass a list to Python threading.Thread?
In the beflow example, I am converting the list to a dictionary. Is there a way to pass list as such to doWork method?

    def launcher():
        list = ['name1', 'name2', 'name3','name4']
        nameList = { 'names' : list }
        workThread = threading.Thread(target=self.doWork, kwargs=nameList)

    def doWork(self, **kwargs):
        for i, name in enumerate(kwargs['nameList']):
            print i, name

Source: python

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.