peter at engcorp.com
Tue Jul 12 05:41:06 CEST 2005
David Isaac wrote:
> Why don't tuples support an index method?
> It seems natural enough ...
This question has been posed several (many?) times in the past. See the
archives for more detail, but basically the answer that is usually given
Tuples are intended to be used somewhat like C "structs", or Pascal
"records", which is to say they should contain heterogeneous sequences
of information for which the concept of ".index()" is fairly
meaningless. They are _not_ generally intended to be used as "read-only
lists", and that's basically why .index() wasn't defined for them.
Another answer that probably follows close on the heels of that one is
along the lines of "patches are always welcome", but I honestly don't
know if a patch to add this would be accepted. Probably checking
Sourceforge for past patches would give an answer, since it seems likely
someone has already tried.
More information about the Python-list