Simple - looking for a way to do an element exists check..

rh0dium steven.klass at
Fri Feb 22 18:20:15 CET 2008

Hi all,

I have a simple list to which I want to append another tuple if
element 0 is not found anywhere in the list.

element =  ('/smsc/chp/aztec/padlib/5VT.Cat',
  '5VT.Cat', (33060))

element1 =  ('/smsc/chp/aztec/padlib/5VT.Cat2',
  '5VT.Cat2', (33060))

a =  [ ('/smsc/chp/aztec/padlib/5VT.Cat',
  '5VT.Cat', (33060)),
  'padlib.TopCat%', (33204)),
  'Regulators.Cat%', (33204))]

So my code would look something like this.

found = False
for item in a:
  if item[0] == element[0]
    found = True
if not found:

But this is just ugly - Is there a simpler way to interate over all
items in a without using a found flag?


More information about the Python-list mailing list