On 11/30/2009 1:25 AM, Russell Warren wrote:


Maybe it's just that * is strictly for arguments, and trying it for
generic tuple unpacking is abuse (which is down the corridor in 12A).

Because (1, 2, *x) == (1, 2, 3, 4) is not tuple unpacking [!]


Tuple unpacking is related with assignment, e.g.:
a, b, c = 1, 2, 3

In python 3, there is the extended tuple unpacking:
>>> a, b, *c = [1, 2, 3, 4, 5]
>>> # a = 1; b = 2; c = [3, 4, 5]
>>> a, *b, c = [1, 2, 3, 4, 5]
>>> # a = 1; b = [2, 3, 4]; c = 5


If I remember correctly, the idea of (1, 2, *x) to mean (1, 2) + x has been discussed before, and rejected as well.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to