tuple.index()

J. Clifford Dyer webmaster at cacradicalgrace.org
Tue Dec 19 13:24:59 EST 2006


Nick Maclaren wrote:
> In article <em90d9$aua$2 at aioe.org>,
> "J. Clifford Dyer" <webmaster at cacradicalgrace.org> writes:
> |> 
> |> How about: "A heterogenous sequence is one in which each element plays a
> |> unique role, specific to its position in the sequence.  A homogenous
> |> sequence is one in which position is determinative of nothing
> |> significant other than (perhaps) order."
> 
> Nope.  Sorry.  Consider the old model where an I/O list is an ordered
> sequence of strings and agents (effectively procedure calls), with no
> constraints on how those are ordered.  With your specification, that
> is neither heterogenous nor homogenous :-)

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.


> 
> |> I doubt the python interpreter will ever try to enforce
> |> homogeneity/heterogeneity on lists/tuples, in part because there no good
> |> ways of definining it syntactically, and in part because there are
> |> certainly good reasons for breaking the rules.  As someone said: passing
> |> lists to untrustworthy functions.  And as someone else said, *args
> |> passes a tuple, even though it is frequently just a homogenous list of
> |> more arguments.
> 
> It's a complete delusion, because even the claimed assumption of list
> homogeneity is tantmount to saying that Python doesn't encourage (or,
> arguably, support) ANY way of using mutable heterogenous sequences
> (such as the example above).  To claim that they are inherently an
> undesirable programming practice is a clear descent into religion!
>
> I would be amused to know what Python type the "lists are intended to
> be homogenous" people use to implement mutable heterogenous sequences,
> or whether they claim that wanting such a feature is heresy :-)
> 

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.

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.  :)


> 
> Regards,
> Nick Maclaren.
> 
> 

Blessings,
Cliff





More information about the Python-list mailing list