Super Tuples

Paul Prescod paul at prescod.net
Mon Dec 27 05:55:34 EST 1999


I propose that in Python 1.6 tuples be given the demonstrated features:

>>> time = (hour=24, minute=00, second=00 )

>>> print time.hour
24

>>> hr, min, sec = time
>>> print hr, min, sec
(24, 00, 00 )
>>> min, sec, hr = time
>>> print min, sec, hr 
(24, 00, 00 )

(this last just demonstrates that tuples continue to work the way they
always have. There is no magic about looking at the names of
assignments)

This proposal has the following benefits:

 * it makes a nice syntax for a 1-item tuple :)
 * it makes a nice syntax for non pre-declared struct-like things
 * it aligns better with the mathematical notion of tuple
 * the element referencing syntax is much clearer
 * names are easier to remember and less error prone than indexes.
 * it is still easy to rip them apart

This proposal may lead some to consider the unification of tuples and
object instances, which is also a discussion worth having.

Opinions? Bets that Guido would apply a patch to this effect?

 Paul Prescod




More information about the Python-list mailing list