Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17049

Re: Verbose and flexible args and kwargs syntax

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 <python-python-list@m.gmane.org>
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 <tjreedy@udel.edu>
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 <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3550.1323705162.27778.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Verbose and flexible args and kwargs syntax Terry Reedy <tjreedy@udel.edu> - 2011-12-12 10:52 -0500
  Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-12 09:12 -0800
    Re: Verbose and flexible args and kwargs syntax Terry Reedy <tjreedy@udel.edu> - 2011-12-12 16:58 -0500
      Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-12 15:40 -0800
        Re: Verbose and flexible args and kwargs syntax Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-12 18:41 -0700
          Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 00:44 -0800
            Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 01:26 -0800
            Re: Verbose and flexible args and kwargs syntax Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-13 11:15 -0700
              Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 12:32 -0800
      Re: Verbose and flexible args and kwargs syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-13 01:34 +0000
    Re: Verbose and flexible args and kwargs syntax alex23 <wuwei23@gmail.com> - 2011-12-12 16:27 -0800
      Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 00:30 -0800
        Re: Verbose and flexible args and kwargs syntax Cameron Simpson <cs@zip.com.au> - 2011-12-14 06:11 +1100
          Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 12:14 -0800

csiph-web