[Python-Dev] Re: syntactic shortcut - unpack to variably sized list
Terry Reedy
tjreedy at udel.edu
Fri Nov 19 21:06:27 CET 2004
"Carlos Ribeiro" <carribeiro at gmail.com> wrote in message
news:864d37090411190724440dfe38 at mail.gmail.com...
> For more than a few arguments, it seems to be silly to require the
> user to write it as:
> a,b,c,d,e = t[0],t[1],t[2],t[3],t[4:]
and also impossible.
>>> t=range(10)
>>> a,b,c,d=t[:4]; e=t[4:]
>>> a,b,c,d,e
(0, 1, 2, 3, [4, 5, 6, 7, 8, 9])
but this does require that return values be captured in a temporary first.
This issue has come up enough that a PEP would be useful (if there isn't
one already).
Terry J. Reedy
More information about the Python-Dev
mailing list