[Python-3000] PEP 3132: Extended Iterable Unpacking

Georg Brandl g.brandl at gmx.net
Wed May 2 23:31:40 CEST 2007

Guido van Rossum schrieb:

>> > 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.
> Hopefully it's possible to only allow this if there's at least one comma?

That's easy. But now that I have lightened the grammar changes a bit, catching
the no-comma case has gotten a bit hairy, as you'll see in the patch.

> In any case the grammar will probably end up accepting *a in lots of
> places where it isn't really allowed and you'll have to fix all of
> those.

In fact it's not too hard: only store context is allowed.

> That sounds messy; only allowing *a at the end seems a bit more
> manageable. But I'll hold off until I can shoot holes in your
> implementation. ;-)

The patch is at http://python.org/sf/1711529. Have fun :)


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.

More information about the Python-3000 mailing list