Tuples -- who needs 'em

Greg Ewing greg at cosc.canterbury.ac.nz
Wed Apr 5 00:28:50 EDT 2000


Bob Alexander wrote:
> 
> BTW, both tuples and lists are ordered collections of non-homogeneous values
> (i.e. the elements can be if different types).

In Haskell, a statically-typed language which also has
both tuples and lists, the two types play distinctly
different roles, and both are needed. A tuple is a 
fixed-size structure whose elements may be of different 
types, whereas a list is a variable-size structure whose 
elements must be of the *same* type.

This is the way I tend to use them in Python as well --
lists for homogeneous collections, tuples for "records".

If static typing is introduced into Python, a more rigid
distinction may have to be made, in which case we may be
glad that we already have the two kinds of structure.

-- 
Greg Ewing, Computer Science Dept,
+--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+



More information about the Python-list mailing list