[Python-3000] Using *a for packing in lists and other places
Marcin ‘Qrczak’ Kowalczyk
qrczak at knm.org.pl
Mon Mar 17 11:56:52 CET 2008
Dnia 16-03-2008, N o godzinie 18:20 -0400, Terry Reedy pisze:
> The rule I suggested is 'execute the statement the same *as if* the
> iterable items had been written in the code as a comma sequence'.
One reason I don't like this rule is that it works on the level of the
token sequence rather than the AST. It's too low-level, relying on
peculiarities of the syntax rather than the meaning (does a=*b really
convert b to a tuple only because the tuple syntax uses lone commas?).
And it doesn't directly work for 0 or 1 items, in which case the
behavior must be extrapolated from the behavior for more items.
In my view the expression-level *a should be allowed in explicitly
listed contexts, mostly where there is already a sequence of expressions
to splice into: lists, tuples, sets, argument lists. And also in yield
and comprehensions, where it would be something new, allowing to
actually create the sequence which always had a single element before.
--
__("< Marcin Kowalczyk
\__/ qrczak at knm.org.pl
^^ http://qrnik.knm.org.pl/~qrczak/
More information about the Python-3000
mailing list