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

From Terry Reedy <tjreedy@udel.edu>
Subject Re: Verbose and flexible args and kwargs syntax
Date 2011-12-12 10:52 -0500
References <4EE5C576.2000307@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3550.1323705162.27778.python-list@python.org> (permalink)

Show all headers | 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