Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43644
| Date | 2013-04-15 15:16 -0600 |
|---|---|
| From | Michael Torrie <torriem@gmail.com> |
| Subject | Re: Process tuple contents on the fly |
| References | <f51058c3-0e36-429c-85d9-365be82b548f@googlegroups.com> <nvZat.526374$Hg7.243527@newsfe30.iad> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.648.1366060603.3114.python-list@python.org> (permalink) |
On 04/15/2013 02:35 PM, Tobiah wrote: > On 04/15/2013 11:25 AM, Gnarlodious wrote: >> Say I have a tuple I want to expand assigning to variables: >> >> tup = *func() > > What is the asterisk for? I assume it's a python 3 > thing, because I get a syntax error, but I'm having > trouble Googling it. No it's not. It's a tuple unpack operator. It's commonly used in this context: def func1(*args, **kwargs): #func1 can take variable args # do stuff func2( *args ) #unpack the variable args and pass them to func2 func3( *args ) func4( *args, **kwargs) def func2( a, b, c): d = a + b + c def func3 ( *args ): pass def func4 ( *args, **kwargs): pass func1(1,2,3)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Process tuple contents on the fly Gnarlodious <gnarlodious@gmail.com> - 2013-04-15 11:25 -0700
Re: Process tuple contents on the fly Tim Chase <python.list@tim.thechases.com> - 2013-04-15 13:50 -0500
Re: Process tuple contents on the fly Barrett Lewis <musikal.fusion@gmail.com> - 2013-04-15 12:05 -0700
Re: Process tuple contents on the fly Peter Otten <__peter__@web.de> - 2013-04-15 21:07 +0200
Re: Process tuple contents on the fly Tim Chase <python.list@tim.thechases.com> - 2013-04-15 14:10 -0500
Re: Process tuple contents on the fly Barrett Lewis <musikal.fusion@gmail.com> - 2013-04-15 12:16 -0700
Re: Process tuple contents on the fly MRAB <python@mrabarnett.plus.com> - 2013-04-15 20:29 +0100
Re: Process tuple contents on the fly Tobiah <toby@tobiah.org> - 2013-04-15 13:35 -0700
Re: Process tuple contents on the fly Michael Torrie <torriem@gmail.com> - 2013-04-15 15:16 -0600
Re: Process tuple contents on the fly Gnarlodious <gnarlodious@gmail.com> - 2013-04-15 16:46 -0700
csiph-web