title: Using list comprehension for finding 1 element in a list?
body: <p>I have a quick question regarding best practices for Python. I've seen where lambda + filter functions were used over list comprehension, but I wanted to know if there's an easier way for finding a specific element in a list without the need to generate and iterate throughout the entire list.</p>
  
  <p>Using the AWS boto3 library, I'm querying various get_x() functions by using list comprehension:</p>
  
  <p><code>[i['domainName'] for i in domain_names['items'] if re.search(r'\b'+domain_name, i['domainName'])].pop()</code></p>
  
  <p><code>[i['id'] for i in usage_plans['items'] if i['name']==f'{self.service}Usage'].pop()</code></p>
  
  <p>If there isn't an item found, an IndexError will be captured and relayed back to the user. Since this is in an AWS Lambda function, I'm worried about scalability and runtime billing for the function.</p>
  
  <p>Should I keep using the list comprehension the way I'm going about it, or is there a better way?</p>