Check if list of objects contain an object with a certain attribute value Check if list of objects contain an object with a certain attribute value python python

Check if list of objects contain an object with a certain attribute value


As you can easily see from the documentation, the any() function short-circuits an returns True as soon as a match has been found.

any(x.name == "t2" for x in l)