tuples, index method, Python's design

Alan Isaac aisaac at american.edu
Sat Apr 7 22:40:52 EDT 2007


"Carsten Haese" <carsten at uniqsys.com> wrote in message
news:mailman.6146.1175956040.32031.python-list at python.org...
> Adding useless features always makes a product worse. What's your use
> case for tuple.index?

I find this question odd for the following reason:
I doubt that *anyone* who programs in Python
has not encountered the situation where they change
a tuple to a list *solely* for the purpose of getting
access to the index method.  There is simply no
conflict between the index method and immutability,
but at the moment you are forced to choose.

Anyway, for a simple use case, consider a game,
where the fixed set p of players have a fixed order.
A tuple is natural.  Now for a player you want to
construct the opponents.  If I had the index i it wd
be p[:i]+p[i+1:], but how to get the index?

Cheers,
Alan Isaac





More information about the Python-list mailing list