On 5/1/07, Guido van Rossum <[EMAIL PROTECTED]> wrote:

On 5/1/07, Georg Brandl <[EMAIL PROTECTED]> wrote:
> This is a bit late, but it was in my queue by April 30, I swear! ;)

Accepted.

> Comments are appreciated, especially some phrasing sounds very clumsy
> to me, but I couldn't find a better one.
>
> Georg
>
>
> PEP: 3132
> Title: Extended Iterable Unpacking
> Version: $Revision$
> Last-Modified: $Date$
> Author: Georg Brandl <[EMAIL PROTECTED]>
> Status: Draft
> Type: Standards Track
> Content-Type: text/x-rst
> Created: 30-Apr-2007
> Python-Version: 3.0
> Post-History:
>
>
> Abstract
> ========
>
> This PEP proposes a change to iterable unpacking syntax, allowing to
> specify a "catch-all" name which will be assigned a list of all items
> not assigned to a "regular" name.
>
> An example says more than a thousand words::
>
>     >>> a, *b, c = range(5)
>     >>> a
>     0
>     >>> c
>     4
>     >>> b
>     [1, 2, 3]

Has it been pointed out to you already that this particular example is
hard to implement if the RHS is an iterator whose length is not known
a priori? The implementation would have to be quite hairy -- it would
have to assign everything to the list b until the iterator is
exhausted, and then pop a value from the end of the list and assign it
to c. it would be much easier if *b was only allowed at the end. (It
would be even worse if b were assigned a tuple instead of a list, as
per your open issues.)



If a clean implementation solution cannot be found then I say go with the
last-item-only restriction.  You still get the nice functional language
feature of car/cdr (or x:xs if you prefer ML or Haskell) without the
implementation headache.  I mean how often do you want the head and tail
with everything in between left together?  If I needed that kind of sequence
control I would feed the iterator to a list comp and get to the items that
way.

Also, what should this do? Perhaps the grammar could disallow it?

*a = range(5)



I say disallow it.  That is ambiguous as to what your intentions are even if
you know what '*' does for multiple assignment.

-Brett
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to