Quick Python Q, parameter passing interpretation help needed

Hi

This python code has a (,) segment  t = Thread(target=myfunc, args=(i,))

what does the (,)) mean? precisely one argument passed in? No second argument?

import time
from threading import Thread

def myfunc(i):
    print "sleeping 5 sec from thread %d" % i
    time.sleep(5)
    print "finished sleeping from thread %d" % i

for i in range(10):
    t = Thread(target=myfunc, args=(i,))
    t.start()

Open in new window

LVL 1
beavoidAsked:
Who is Participating?
 
aikimarkCommented:
Thread is defined as follows:

|  __init__(self, group=None, target=None, name=None, args=(), kwargs=None, verbose=None)
|      This constructor should always be called with keyword arguments. Arguments are:
|
|      *args* is the argument tuple for the target invocation. Defaults to ().
This means that it expects arts to be a tuple.  Since only one value is supplied, it requires the comma
0
 
beavoidAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.