On 15 December 2011 17:53, Steven D'Aprano <steve@pearwood.info> wrote:
Michael Foord wrote:
On 15 December 2011 17:35, Alexander Heger <python@2sn.net> wrote:

Dear Masklinn,

thanks for your suggested solution.

I know all of these, but
1) it is not as elegant or short
2) why does unpacking not work syntactically the same as for the function
parameters?
It seems a natural extension that appears not to have a syntactic
conflict.  If it is not even a necessity for consistency.

So, the point is not that something like
[0,*x,0,*y,0]
can't be done in other ways, but that it can't be done in a neat way.



I quite like that (suggested) syntax.

So do I. But I question the need for it.

+0.


Well, the new tuple unpacking syntax makes it easy to work with the head and tail of a sequence:

    head, *rest = some_sequence
   *rest, tail = some_sequence

This syntax provides a corollary:

    some_sequence = (head, *rest)
    some_sequence = (*rest, tail)

Tuple unpacking like this being the equivalent of car and cdr, with the corollary being the equivalent of cons. (Given my limited understanding of these operations.)

Michael
 

--
Steven

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas



--
http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html