Q:

Python pass argument to Thread class

Python beginners question.  I have seen many examples here with "old" way to create threads but not so many examples of how to pass arguments to a thread class.  My code is like below... I have tried a number of different ways but no luck yet.  Any help much appreciated
class downloadToWorldThread (threading. Thread):
    def __init__(self, threadID, name, counter,args=(arg1,arg2,arg3)): 
        threading. Thread.__init__(self)
        self.threadID = threadID
        self.name = name
        self.counter = counter
        self.args.arg1 = arg1
        self.args.arg2 = arg2

        ## or this? 
        #self.args.arg1 = args.arg1
        #self.args.arg2 = arg2.arg2

    def run(self):
        ##how do i access individual args? 
        print "Starting " + self.name
        print "arg is " +  self.args.arg2

        downloadToMyHouse(self.args.arg1,self.args.arg2,self.args.arg3)
        print "Exiting " + self.name

def downloadAllToWorld(aaa,bbb,ccc,ddd,eee,fff):

    # Create new threads
    ##thread
    thread1 = downloadToWorldThread(1, "blah1-1", 1,args=(arg1,arg2,arg3))
    ##thread2
    thread2 = downloadToWorldThread(2, "blah2-2", 2, args=(arg1,arg2,arg3))

A:

I am not entirely sure I understand why you are creating a new sub-class for the thread.  But if you want to pass the args to the subclass you should do something:
class downloadAllToWorldThread(threading. Thread):
    def __init__(self, threadID, name, counter, *args):
        threading. Thread.__init__(self)
        self.threadID = threadID
        self.name = name
        self.counter = counter
        self.args = args
    def run(self):
        print('Args are: {}'.format(self.args))
        downloadToMyHouse(self.args[0],self.args[1],self.args[2])

def downloadAllToWorld(aaa,bbb,ccc,ddd,eee):
    thread1 = downloadAllToWorldThread(1,"blah1-1", 1, ccc, ddd, eee)

args is used to pass arguments to a function when the number of argument is not known.  In this case the values passed as args list are: ccc, ddd, eee .  Please do note that args is a list of arguments so you can access its element just by using "[ ]".