How come tuples don't have an index method?

Tim Peters tim.one at home.com
Fri Sep 7 13:25:43 EDT 2001


[Michael Abbott and Terry Reedy, wonder why tuples don't have index()
 and count() methods]
> ...
> so I see no good reason not to give tuples methods also.
> Seems like a PEP project.

It's already been implemented and rejected:

http://sf.net/tracker/?group_id=5470&atid=305470&func=detail&aid=403693

In 2.2, operator.countOf() works on any iterable object:

C:\Code\python\PCbuild>python
Python 2.2a2+ (#23, Sep  6 2001, 20:10:09) [MSC 32 bit (Intel)] on win32
>>> import operator
>>> operator.countOf((1,2,3,1,2,3,2,2,2), 2)
5
>>>





More information about the Python-list mailing list