tuple.index()

J. Clifford Dyer webmaster at cacradicalgrace.org
Mon Dec 18 18:50:42 EST 2006


James Stroud wrote:
> Christoph Zwerschke wrote:
>> "Inhomogenous" in some meaning of the word --> tuple
> 
> I think that you have nailed it here. I don't think anyone on this list
> is capable of giving a "concrete" (as you have put it) operational
> definition of "inhomogenous". They will resort to use cases and thus
> cloud the definition with programming philosophy.
> 

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."

I'm not exactly sure what you mean by "programming philosophy."  I
suspect it does enter into the choice of which to use, (as programming
philosophy determines whether a database will have a "name" field, or
"lastname", "firstname", and "middlename" fields)  but I don't see that
this clouds the definitions, necessarily.

> So, programming philosophy, whether it will be admitted or not, is fully
> responsible for the exclusion of index() from the tuple interface.
> 

No.  Because as pointed out in another subthread, the exclusion of
index() from the tuple interface is in many ways orthogonal to the issue
of homogeneity/heterogeneity.  It's partly that, and partly that The
Maintainers have decreed that the workarounds (list(mytuple).index())
are trivial enough to obviate the need for making all the changes to the
source code, and hacking something ugly (a linear search has been
suggested) into all unsuspecting hand-rolled subscriptable objects.


> But perhaps we could take "not necessarily homogenous" to be the
> operational definition of "inhomogenous". Of course then we would have
> to define necessary...
> 
> James

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.

Forgive me for referencing throughout the threads without proper
citation.  I've been ill all weekend, and I just don't feel like doing
it right.

Cheers,
Cliff



More information about the Python-list mailing list