Re: *args question

2009-04-02 Thread Aahz
In article <50d06eb9-2b87-43a0-a7e2-6b68e35fc...@y34g2000prb.googlegroups.com>, grocery_stocker wrote: > >Given the following code... > >import thread Here's your problem; subclass threading.Thread instead, much easier. -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft

Re: *args question

2009-03-25 Thread Dave Angel
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 synt

Re: *args question (correction)

2009-03-25 Thread Tim Chase
thread.start_new_thread(myfunc, "some string", 42) This should have been thread.start_new_thread(myfunc, ("some string", 42)) because all the subsequent values after the function-handle/name get passed into the function when it gets called. As if the start_new_thread() function was def

Re: *args question

2009-03-25 Thread Tim Chase
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 take

Re: *args question

2009-03-25 Thread grocery_stocker
On Mar 25, 8:28 am, Tim Chase wrote: > grocery_stocker wrote: > > On Mar 25, 7:05 am, grocery_stocker wrote: > >> Given the following code... > > >> #!/usr/bin/env python > > >> import time > >> import thread > > >> def myfunction(string,sleeptime,*args): > >> while 1: > > >> print st

Re: *args question

2009-03-25 Thread Tim Chase
grocery_stocker wrote: On Mar 25, 7:05 am, grocery_stocker wrote: Given the following code... #!/usr/bin/env python import time import thread def myfunction(string,sleeptime,*args): while 1: print string time.sleep(sleeptime) #sleep for a specified amount of time. if __

Re: *args question

2009-03-25 Thread John Machin
On Mar 26, 1:17 am, grocery_stocker wrote: > On Mar 25, 7:05 am, grocery_stocker wrote: > > > > > Given the following code... > > > #!/usr/bin/env python > > > import time > > import thread > > > def myfunction(string,sleeptime,*args): > >     while 1: > > >         print string > >         time.

Re: *args question

2009-03-25 Thread grocery_stocker
On Mar 25, 7:05 am, grocery_stocker wrote: > Given the following code... > > #!/usr/bin/env python > > import time > import thread > > def myfunction(string,sleeptime,*args): > while 1: > > print string > time.sleep(sleeptime) #sleep for a specified amount of time. > > if __nam

*args question

2009-03-25 Thread grocery_stocker
Given the following code... #!/usr/bin/env python import time import thread def myfunction(string,sleeptime,*args): while 1: print string time.sleep(sleeptime) #sleep for a specified amount of time. if __name__=="__main__": thread.start_new_thread(myfunction,("Thread N