Guido van Rossum schrieb: > 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.
Yes, that is correct. My implementation isn't *that* hairy, though, it's only 13 lines of code more. I'll post the patch to SourceForge later today. > 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.) The created tuple is a fresh one, so can't I just copy pointers like from a list and set ob_size later? > Also, what should this do? Perhaps the grammar could disallow it? > > *a = range(5) I'm not so sure about the grammar, I'm currently catching it in the AST generation stage. Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out. _______________________________________________ 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