Tuples -- who needs 'em

Neel Krishnaswami neelk at brick.cswv.com
Thu Apr 6 01:01:12 CEST 2000


Greg Ewing <greg at cosc.canterbury.ac.nz> wrote:
> 
> 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".
 
Heh. I don't mind having lists and tuples; it's classes and tuples
that are the "same thing", in that both of these are record types. I
think the only reason to get rid of tuples would be if be nicer to
have a simple destructuring/pattern-matching syntax for classes and
instances than currently.

It's hard to overstate how convenient being able to do pattern
matching on tuples is -- it's one of the things that makes Python so
expressive. 

> 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.
 
Indeed. And then I think people would complain about having tuples and
classes. :)


Neel



More information about the Python-list mailing list