[Python-Dev] Extending tuple unpacking
Greg Ewing
greg.ewing at canterbury.ac.nz
Mon Oct 10 04:44:12 CEST 2005
Guido van Rossum wrote:
> I personally think this is adequately handled by writing:
>
> (first, second), rest = something[:2], something[2:]
That's less than satisfying because it violates DRY
three times (once for mentioning 'something' twice,
once for mentioning the index twice, and once for
needing to make sure the index agrees with the number
of items on the LHS).
> Argument lists are not tuples [*] and features of argument lists
> should not be confused with features of tuple unpackings.
I'm aware of the differences, but I still see a strong
similarity where this particular feature is concerned.
The pattern of thinking is the same: "I want to deal
with the first n of these things individually, and the
rest collectively."
--
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg.ewing at canterbury.ac.nz +--------------------------------------+
More information about the Python-Dev
mailing list