"Kent Johnson" <ken...@tds.net> wrote

For what it's worth, Guido has explicitly said,
"Tuples are for heterogeneous data, list are for homogeneous data.
Tuples are *not* read-only lists."

That surprises me, he has always seemed more pragmatist than purist.
However even Guido saying it doesn't alter the fact that in practice it
is not a part of the language, merely a usage pattern. (Of course that
could change in future versions like Python3000 but in the current
incarnation, we have what we have)

Personally, I take this with a grain of salt. I do tend to use tuples
for things that are like records or structs, or often just for pairs
of data (e.g. the elements of dict.items()), and lists for homogeneous collections, but that is more a matter of fitness for the purpose than
dogma.

Precisely. That was the point I tried to make earlier that in most
usage scenarios lists tend to be used homogenously and tuples
heterogenenously. But there is absolutely nothing in Python that
mandates it. A good example of a homogenous tuple is a pair of
values such as a point's x,y coordinates. And heterogenuous lists
are also very useful at times, particularly when the only alternative
would be to define a singleton class...

Alan G.

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to