list.index

Steven Taschuk staschuk at telusplanet.net
Fri Jun 6 13:06:17 EDT 2003


Quoth Fredrik Lundh:
> "delphiro" <delphiro at zonnet.nl> wrote:
> 
> > is this the easiest way to check for the existance of an item in a list?
  [...]
> the usual way to do this is:
> 
>     if self.pointmarker in self.selected_points:
>         colour = DEFAULT_SELECTED_POINT_COLOUR
> 
> you can also use "find", which does the same thing as "index" if
> successful, but returns -1 if the item is not found.

Lists don't have a .find.  (Strings do.)

-- 
Steven Taschuk                            staschuk at telusplanet.net
Every public frenzy produces legislation purporting to address it.
                                                  (Kinsley's Law)





More information about the Python-list mailing list