=?x-gbk?Q?=BB=D8=B8=B4=A3=BA_=28=29_vs_=5B=5D?=
Terry Reedy
tjreedy at udel.edu
Thu Oct 15 14:58:04 EDT 2009
SmokingDog wrote:
> > Interesting interpretation.. but I just gave it a try.
> >
> >>>> a = (1,2,3,4)
> >>>> a
> > (1, 2, 3, 4)
> >>>> a.index(3)
> > 2
> >>>> a.index(5)
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in <module>
> > ValueError: tuple.index(x): x not in tuple
> >
> > So my Python is saying that tuples do implement .index() method. What
> gives?
> >
> > Or maybe the diveintopython version he's quoting is out of date?
>
> Apparently...or something stranger.
The OP did not indicate version, which posters should always do.
methods were added to tuples in 3.0 and perhaps 2.6.
More information about the Python-list
mailing list