tuple.index(item)
Raymond Hettinger
python at rcn.com
Tue Jul 12 01:21:41 EDT 2005
[David Isaac]
> > Why don't tuples support an index method?
> > It seems natural enough ...
[Peter Hansen]
> 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
> is this:
>
> 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.
Executive summary: Guido likes it the way it is. Someday, he may
change his mind. Probably not.
Raymond Hettinger
More information about the Python-list
mailing list