index() of sequence type?
Raymond Hettinger
python at rcn.com
Thu Feb 7 17:13:00 EST 2008
On Feb 7, 1:57 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
> Tuples are worse: they implement
> __contains__ but not index. So you can say:
>
> py> 2 in (1,2,4,8)
> True
>
> but not:
>
> py> (1,2,4,8).index(2)
You must be using an old version of Python like 2.5 ;-)
As of yesterday, Py2.6 has tuple.index() and tuple.count().
Python 2.6a0 (trunk:60638M, Feb 6 2008, 18:10:45)
[GCC 4.1.1 (Gentoo 4.1.1)] on linux2
>>> (1,2,4,8).index(2)
1
Raymond
More information about the Python-list
mailing list