tuple.index()

Nick Maclaren nmm1 at cus.cam.ac.uk
Tue Dec 19 13:58:19 EST 2006


In article <em9aq9$2tn$1 at aioe.org>,
"J. Clifford Dyer" <webmaster at cacradicalgrace.org> writes:
|> 
|> On the contrary, I think that example fits perfectly with my definition
|> of homogenous.  If there is no constraint on position, then what is the
|> position determinative of?  Order in the queue.  Nothing more.  By my
|> definition, homogeneous.  QED.
|> 
|> I'll grant, it's not exactly the most intuitive definition of
|> homogenous, but I think it is the most accurate for this situation.
|> Perhaps homogenous and heterogenous aren't the best possible words here,
|> but I think they work.

Grrk.  I see what you mean.  The homogeneity is referring to the order
and not to the types :-)

|> By my definition, how can it be mutable AND heterogenous?  If the first
|> element is a name, the second element is a phone number, and the third
|> element is an email address, and you insert an element in between the
|> first two elements, do you mean to tell me that the phone number, which
|> has moved to the third slot, is now an email address?  It doesn't make
|> sense.

Well, I could provide an example, but they are a bit weird.  More
seriously, consider changing a structure consisting of a name and
telephone number, and then changing the value of the latter (not
exactly an unreasonable requirement!)  With tuples that can't be done,
but it makes perfect sense, and it is a mutable heterogeneous sequence
with your definition.
 
|> Maybe the words are wrong.  I'm not sure.  But I think the distinction
|> is valid.  Furthermore, I think we "lists are intended to be homogenous"
|> people would say that you are perfectly welcome to use lists for other
|> purposes, if it suits you.  Just as you can use a string as a list.  We
|> don't have to be rigid to appreciate the difference.  :)

Nope.  That is DEFINITELY wrong.  If you write code that abuses a
language construct in a way that is discouraged but just happens to
work, a couple of decades down the line it will stop working, because
someone will change the feature.  Been there - been caught by that :-(


Regards,
Nick Maclaren.



More information about the Python-list mailing list