Python 3.0 - is this true?

"Martin v. Löwis" martin at v.loewis.de
Sun Nov 9 23:49:08 CET 2008


> Hmmm, I seem to have engaged in a bit of topic drift, for which I 
> apologize.  I was commenting specifically on the issue of lists holding 
> heterogeneous types, not on heterogeneous types being sortable.

Still, I don't think this is a valid counter-example: I claim that the
data in the list of tokens is homogeneous (them all being tokens),
despite the individual objects having different types, and potentially
not even a common base class but object.

The "homogeneous vs. heterogeneous" discussion is not that much about
type, but more about semantics of the individual values. If you
represent (firstname, lastname, age), you use tuples - three different
(and orthogonal) pieces of information. There is no canonical way of
continuing that sequence (hence the fixed-size nature of the tuple is
no concern). OTOH, the token list has the structure [token, token, ...].
The third element is semantically not different from the first element,
hence a list is appropriate.

Regards,
Martin



More information about the Python-list mailing list