How come tuples don't have an index method?

Terry Reedy tjreedy at home.com
Fri Sep 7 14:45:52 EDT 2001


"Tim Peters" <tim.one at home.com> wrote in message
news:mailman.999883580.3508.python-list at python.org...
> [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=40369
3
>
> 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

Does it have operator.indexOf ()?  Code would be nearly same.





More information about the Python-list mailing list