Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #68281
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <prvs=14100c93d=jeanmichel@sequans.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.015 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'tutorial': 0.03; 'syntax': 0.04; 'arguments': 0.09; 'subject:create': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'thread': 0.14; 'arg2,': 0.16; 'subject:default': 0.16; 'subject:object': 0.16; 'subject:pass': 0.16; 'syntaxerror:': 0.16; 'threads.': 0.16; 'import': 0.22; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'compilation': 0.24; 'cheers,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'code': 0.31; '"",': 0.31; 'file': 0.32; 'class': 0.32; '-----': 0.33; 'something': 0.35; 'keyword': 0.36; 'subject:?': 0.36; 'hi,': 0.36; 'thank': 0.38; 'skip:- 60': 0.39; 'how': 0.40; 'facebook': 0.61; 'you.': 0.62; 'information': 0.63; 'received:194': 0.64; 'to:addr:gmail.com': 0.65; 'details': 0.65; 'notice:': 0.67; 'invalid': 0.68; 'person,': 0.68; 'default': 0.69; 'privileged.': 0.69; 'disclose': 0.74; 'medium.': 0.91; 'browse': 0.95 |
| X-IronPort-AV | E=Sophos;i="4.97,638,1389740400"; d="scan'208";a="2558413" |
| X-Virus-Scanned | amavisd-new at zimbra.sequans.com |
| Date | Wed, 12 Mar 2014 14:51:15 +0100 (CET) |
| From | Jean-Michel Pichavant <jeanmichel@sequans.com> |
| To | Piyush Verma <114piyush@gmail.com> |
| In-Reply-To | <CAJV9OM_9tg5y5cC_zrzSZ4RVF8VvxqOxE-uhzyKusWPeeC1sxg@mail.gmail.com> |
| Subject | Re: How do we pass default argument value to create thread object? |
| MIME-Version | 1.0 |
| X-Mailer | Zimbra 7.2.4_GA_2900 (ZimbraWebClient - GC33 (Win)/7.2.4_GA_2900) |
| Content-Type | text/plain; charset="utf-8" |
| Content-Transfer-Encoding | base64 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8090.1394632343.18130.python-list@python.org> (permalink) |
| Lines | 25 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1394632344 news.xs4all.nl 2890 [2001:888:2000:d::a6]:56095 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:68281 |
Show key headers only | View raw
----- Original Message -----
> 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 Twitter
Hi,
try something like
thread = threading.Thread(target=Fun, args=("val1", "val2"), kwargs={"arg3":"val3"})
This will call
Fun("val1", "val2", arg3="val3")
Browse the python tutorial for details on arguments and keyword arguments.
Cheers,
JM
-- IMPORTANT NOTICE:
The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How do we pass default argument value to create thread object? Jean-Michel Pichavant <jeanmichel@sequans.com> - 2014-03-12 14:51 +0100
csiph-web