tuples, index method, Python's design

Alan Isaac aisaac at american.edu
Thu Apr 12 14:22:31 EDT 2007


I am still puzzled by this discussion.

As I said:
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. This suggests a missing
method, does it not?  Who has not done this?
Name yourself!

There is simply no conflict between the index method and immutability,
but at the moment one is forced to choose.  Why?  Nobody has
offered a real explanation of this.

I offered 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?

Other use cases have also been offered on this thread.
What is the basic response?  "Do not worry about the
loss of immutability, just use a list."  What kind of a
response is that??  This sounds to me like "I do not
really see the point of immutability", which is no
response at all.

Cheers,
Alan Isaac






More information about the Python-list mailing list