determining the number of output arguments

Jeremy Bowers jerf at jerf.org
Tue Nov 16 06:40:06 EST 2004


On Mon, 15 Nov 2004 19:44:06 -0800, Josiah Carlson wrote:
>> I think it would be better to have a way to say 'and all the rest'.
>> Lacking that, some automated way to count how many items are being
>> unpacked on the LHS is probably second-best.
> 
> Is it worth a keyword, or would a sys.getframe()/bytecode hack be
> sufficient?

Who needs a keyword?

a, b, *c = [1, 2, 3, 4]
a, b, *c = [1, 2]

In the latter case I'd expect c to be the empty tuple.

Clear parallels to function syntax:

>>> def f(a, b, *c):
...     print c
... 
>>> f(1, 2, 3, 4)
(3, 4)
>>> f(1, 2)
()

No parallel for **, but... *shrug* who cares?



More information about the Python-list mailing list