----- Original Message ----- From: QUIN Frédéric <frederic.quin@free.fr> To: <zope@zope.org> Sent: Wednesday, June 07, 2000 6:14 PM Subject: [Zope] How to know if a list contains a specified item ?
Hello everybody,
I would like to know if there is a function which allows to know if a list contains a specified item.
You can use: <dtml-if "list.count(item)"> If you want the (1st) index of the item in list you must use something like <dtml-let item1="1" item2="69"> <dtml-let list="[1,2,3]"> <dtml-try> <dtml-var "list.index(item1)"> <dtml-except>No item <dtml-var item1> </dtml-try> <dtml-try> <dtml-var "list.index(item2)"> <dtml-except>No item <dtml-var item2> </dtml-try> </dtml-let> </dtml-let> you have to use try because "list.index(item)" rise an exception if the "item" is not in list.. PM