"Find" in list of objects

Andreas Müller hufflehuffle at west.de
Thu Oct 23 09:23:51 CEST 2008


(Python 2.2.3 if this is relevant :-)

I have a list of objects with, lets say, the attributes "ID", "x" and
"y". Now I want to find the index of list element with ID=10.

Of course I can loop through the list manually, but is there a
construct like

list.find (10, key='ID')

? Thanks for your ideas.

Best regards,

More information about the Python-list mailing list