title: Check if list of objects contain an object with a certain attribute value
body: <p>I want to check if my list of objects contain an object with a certain attribute value. </p>
  
  <pre><code>class Test:
      def __init__(self, name):
          self.name = name
  
  # in main()
  l = []
  l.append(Test("t1"))
  l.append(Test("t2"))
  l.append(Test("t2"))
  </code></pre>
  
  <p>I want a way of checking if list contains an object with name <code>"t1"</code> for example. How can it be done? I found <a href="https://stackoverflow.com/a/598415/292291">https://stackoverflow.com/a/598415/292291</a>, </p>
  
  <pre><code>[x for x in myList if x.n == 30]               # list of all matches
  any(x.n == 30 for x in myList)                 # if there is any matches
  [i for i,x in enumerate(myList) if x.n == 30]  # indices of all matches
  
  def first(iterable, default=None):
      for item in iterable:
          return item
      return default
  
  first(x for x in myList if x.n == 30)          # the first match, if any
  </code></pre>
  
  <p>I don't want to go through the whole list every time, I just need to know if there's 1 instance which matches. Will <code>first(...)</code> or <code>any(...)</code> or something else do that?</p>