Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; 'args': 0.07; '*args,': 0.09; 'assigning': 0.09; 'python': 0.11; 'def': 0.12; 'assume': 0.14; '**kwargs)': 0.16; '**kwargs):': 0.16; '*args': 0.16; 'c):': 0.16; 'context:': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'googling': 0.16; 'operator.': 0.16; 'tup': 0.16; 'tuple': 0.16; 'unpack': 0.16; 'variables:': 0.16; 'for?': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'header:User-Agent:1': 0.23; 'pass': 0.26; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; "i'm": 0.30; 'commonly': 0.31; 'stuff': 0.32; 'not.': 0.33; 'trouble': 0.34; 'subject:the': 0.34; 'but': 0.35; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'asterisk': 0.84; 'thing,': 0.91 X-Virus-Scanned: amavisd-new at torriefamily.org Date: Mon, 15 Apr 2013 15:16:29 -0600 From: Michael Torrie User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130105 Thunderbird/10.0.12 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Process tuple contents on the fly References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1366060603 news.xs4all.nl 2574 [2001:888:2000:d::a6]:56747 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43644 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)