tuple.index()

Nick Maclaren nmm1 at cus.cam.ac.uk
Tue Dec 19 05:01:47 EST 2006


In article <4587506D.50808 at cosc.canterbury.ac.nz>,
greg <greg at cosc.canterbury.ac.nz> writes:
|> Nick Maclaren wrote:
|> 
|> > Unfortunately, you are confusing the issue, because there are far
|> > more extraneous aspects than relevant ones, and your view of the
|> > similarities requires looking at the issue in a very strange way.
|> > I think that I can see what you mean, but only just.
|> 
|> Each member of a struct has a distinct, predefined
|> role. Even if they all have the same type, you
|> can't swap their values around without destroying
|> the meaning of the data. That's what's meant by
|> "heterogeneous" in this context -- it's not about
|> the values themselves, but the way they're used.
|> 
|> This is the kind of thing for which Python tuples
|> are mainly designed -- use as a struct whose
|> members happen to be named by integers rather
|> than strings.

Well, that was obvious to me on a cursory reading, because I have
enough relevant experience with other languages.  It wasn't what I
was referring to, which was two things:

    C arrays are not extensible and, before C99, were fixed in size
at compile time.  That makes them rather more similar to tuples in
those ways!  I know that's not the aspect you were thinking of, but
is why I made the remark that I did.

    It does explain why you think of lists as homogeneous, but the
analogy doesn't hold water on closer inspection.  There doesn't seem
to be ANYTHING in the specification or implementation that assumes
lists are homogeneous.


Regards,
Nick Maclaren.



More information about the Python-list mailing list