How do we pass default argument value to create thread object?

Piyush Verma 114piyush at gmail.com
Wed Mar 12 09:09:27 EDT 2014


Hi,

I am using Thread class to create threads.
<CODE>
thread = threading.Thread(target=Fun, args=[arg1, arg2, arg3="val"])
thread.start()
</CODE>

This code is throwing compilation error(Ipython).
In [19]: import threading

In [20]: def Fun(agr1, arg2, arg3=None):
   ....:     pass
   ....:

In [21]: thread = threading.Thread(target=Fun, args=[arg1, arg2, arg3="val"
])
------------------------------------------------------------
   File "<ipython console>", line 1
     thread = threading.Thread(target=Fun, args=[arg1, arg2, arg3="val"])
                                                                 ^
SyntaxError: invalid syntax

How do we pass the value to default arguments while creating thread object?

Regards,
~Piyush
Facebook <https://www.facebook.com/piyushkv1>
Twitter<https://twitter.com/SocializePiyush>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140312/df2bfbbe/attachment.html>


More information about the Python-list mailing list