title: Find first element in a sequence that matches a predicate
body: <p>I want an idiomatic way to find the first element in a list that matches a predicate.</p>
  
  <p>The current code is quite ugly:</p>
  
  <pre><code>[x for x in seq if predicate(x)][0]
  </code></pre>
  
  <p>I've thought about changing it to:</p>
  
  <pre><code>from itertools import dropwhile
  dropwhile(lambda x: not predicate(x), seq).next()
  </code></pre>
  
  <p>But there must be something more elegant... And it would be nice if it returns a <code>None</code> value rather than raise an exception if no match is found.</p>
  
  <p>I know I could just define a function like:</p>
  
  <pre><code>def get_first(predicate, seq):
      for i in seq:
          if predicate(i): return i
      return None
  </code></pre>
  
  <p>But it is quite tasteless to start filling the code with utility functions like this (and people will probably not notice that they are already there, so they tend to be repeated over time) if there are built ins that already provide the same.</p>