list.index

POYEN OP Olivier (DCL) Olivier.POYEN at clf-dexia.com
Fri Jun 6 09:59:58 EDT 2003



> -----Message d'origine-----
> De : delphiro [mailto:delphiro at zonnet.nl]
> Envoyé : vendredi 6 juin 2003 15:50
> À : python nieuwsgroep
> Objet : list.index
> 

> 
> is this the easiest way to check for the existance of an item 
> in a list?
> it looks a bit weird to check a for a listitem by using a 
> try..except block
> 
> (code background; if the item is found the colour should 
> change else the colour that was already given is ok)
> [mycode]
> try:
>   x = self.selected_points.index( self.pointmarker )
>   colour = DEFAULT_SELECTED_POINT_COLOUR
> except ValueError:
>   pass
> [/mycode]
> 


It seems weird by it's quite ok to do that in python.
AFAIR, I think it's even the purpose of the try/except block.


HTH,

OPQ
 
-------------- next part --------------
-----------------------------------------------------------------

Ce message est confidentiel ; son contenu ne represente en aucun

cas un engagement de la part de Dexia Credit Local ou de Dexia

CLF Banque. Toute publication, utilisation ou diffusion, meme

partielle, doit etre autorisee prealablement par l'emetteur. Si

vous n'etes pas destinataire de ce message, merci d'en avertir

immediatement l'expediteur.



This message is confidential ; its contents do not constitute a

commitment by Dexia Credit Local or Dexia CLF Banque. Any

unauthorised disclosure, use or dissemination, either whole or

partial, is prohibited. If you are not the intended recipient of

the message, please notify the sender immediately.

-----------------------------------------------------------------

Consultez notre site internet www.dexia-clf.fr

La cle d'une gestion optimisee du secteur public local

-----------------------------------------------------------------


More information about the Python-list mailing list