tuples, index method, Python's design

Carsten Haese carsten at uniqsys.com
Fri Apr 6 21:24:17 CEST 2007


On Fri, 2007-04-06 at 11:33 -0700, 7stud wrote:
> On Apr 6, 7:56 am, "Paul Boddie" <p... at boddie.org.uk> wrote:
> > The problem with 7stud's quote from GvR is that it's out of date:
> 
> I would argue that it shows the very guy who invented the language
> stated publicly there was no good reason for tuples not to have an
> index method---except for consistency; tuples had no other methods.
> Now that tuples have other methods, the only justification he stated
> no longer exists.

Except that that wasn't the only justification. GvR also said:

"""
For tuples, I suspect such a function would rarely be used; I think
that is most cases where x.index() would be useful, x is generally a
list, whose contents varies in time, rather than a tuple (which cannot
change easily).
"""

The lack of convincing use cases is still a pertinent reason today. Note
that the original poster on this thread did not present a use case for
tuple.index, they were only asking out of curiosity.

If you have a use case for tuple.index, please show it to me, and I'll
show you what you should be using instead of a tuple.

-Carsten





More information about the Python-list mailing list