tuples, index method, Python's design

Hendrik van Rooyen mail at microcorp.co.za
Wed Apr 11 02:57:43 EDT 2007


"Carsten Haese" <carsten at uniqsys.com> wrote:


> I'm just a user with no influence on the development of Python itself,
> but in my humble opinion, the non-existence of tuple.index is more
> pythonic than its existence would be.

I really cannot follow the logic behind this statement.
I can write:

L = [a,b,c,d,e,f]
T= (a,b,c,d,e,f)

The difference between the two things is that I can add to 
and change L, but not T.

Now it seems to me that whatever argument is used to
justify the existence of:

n = L.index(d)

can be used to justify the existence of:

n = T.index(d)

and vice versa.

Cut down to these basics, it seems to me that the arguments
against the latter construct are simply knee jerk reactions
to preserve the status quo.

If an index method for tuples is such a very bad thing,
then the same arguments can be used to justify the
removal of the list index method from the language.

I happen to agree with Antoon - there is a LOT of merit
in consistency, as it makes things easy to learn and remember.

And I would heretically go even further, and argue that it
should be possible to write stuff like:

T = T.append(x)

And get back a new tuple bound to the old name...

- Hendrik





More information about the Python-list mailing list