Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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; 'received:verizon.net': 0.07; 'terry': 0.07; 'python': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'am,': 0.12; '(1,': 0.16; '3],': 0.16; '[2,': 0.16; 'a,b,c': 0.16; 'general.': 0.16; 'is;': 0.16; 'mutated': 0.16; 'reedy': 0.16; 'sequence.': 0.16; 'subject:syntax': 0.16; 'unpacking': 0.16; 'unpacking.': 0.16; 'examples': 0.16; 'language': 0.17; 'wrote:': 0.18; '>>>': 0.18; 'jan': 0.19; 'header:In-Reply-To:1': 0.22; 'specifically': 0.27; 'not.': 0.28; 'repeatedly': 0.28; 'cases.': 0.30; 'tail': 0.30; 'quite': 0.32; 'does': 0.32; 'represents': 0.32; 'words,': 0.32; 'header:User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.33; 'to:addr:python-list': 0.34; 'things': 0.34; 'question': 0.36; 'for?': 0.37; 'sequence': 0.37; 'but': 0.37; 'think': 0.37; 'received:org': 0.38; 'useful': 0.38; 'represent': 0.39; 'to:addr:python.org': 0.40; 'more': 0.61; 'design': 0.61; 'your': 0.61; 'our': 0.64; 'anything.': 0.71; 'specialized': 0.72; 'seldom': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Verbose and flexible args and kwargs syntax Date: Mon, 12 Dec 2011 10:52:25 -0500 References: <4EE5C576.2000307@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-74-109-121-73.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: <4EE5C576.2000307@gmail.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1323705162 news.xs4all.nl 6881 [2001:888:2000:d::a6]:48577 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17049 On 12/12/2011 4:12 AM, Eelco Hoogendoorn wrote: >> The above examples are seldom needed in Python because we have one >> general method to repeatedly split a sequence into head and tail. > >> it = iter(iterable) # 'it' now represents the sequenced iterable >> head = next(it) # 'it' now represents the tail after removing the head > >> In other words, next(it) encompasses all of your examples and many more. >> Because 'it' is mutated to represent the tail, it does not need to be >> rebound and therefore is not. > > > The question in language design is never 'could we do these things > before'. The answer is obvious: yes our CPUs are turing complete; we can > do anything. The question is; how would we like to do them? > > So do you think the new head/tail unpacking features in python 3 are > entirely uncalled for? No, *target unpacking (singular) is quite useful in specialized cases. But it is not specifically head/tail unpacking. >>> a,*b,c = 1,2,3,4,5,6 >>> a,b,c (1, [2, 3, 4, 5], 6) >>> *a,b,c = 1,2,3,4,5 >>> a,b,c ([1, 2, 3], 4, 5) > I personally quite like them, but I would like them to be more general. It already is. The *target can be anywhere in the sequence. -- Terry Jan Reedy