Try the following, to call your function yourself in this way:


def myfunction(string,sleeptime,*args):
    while 1:

        print "string is ", string
        time.sleep(sleeptime) #sleep for a specified amount of time.

f = myfunction
r = ("Thread No:1",2)
f(*r)

The key here is the *r syntax, which is used in a function call to turn a tuple (or list) into a separate set of arguments. It's kind of the inverse of the *args you're already using.

DaveA

grocery_stocker wrote:
On Mar 25, 8:28 am, Tim Chase <python.l...@tim.thechases.com> wrote:
grocery_stocker wrote:
<.... portions deleted ......>
Maybe I'm missing it, but in the original code, the line had

thread.start_new_thread(myfunction,("Thread No:1",2))

It has a single arg  ("Thread No:1",2) versus something like

thread.start_new_thread(myfunction,1, 2, ("Thread No:1",2))

But

def myfunction(string,sleeptime,*args):

clearly takes two args. I don't get how the single arg ("Thread No:1",
2) in start_new_thread() gets magically converted two arges, string
and sleeptime, before it reaches myfunction().

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to