title: Get index in the list of objects by attribute in Python
body: <p>I have list of objects with attribute id and I want to find index of object with specific id. I wrote something like this:</p>
  
  <pre><code>index = -1
  for i in range(len(my_list)):
      if my_list[i].id == 'specific_id'
          index = i
          break
  </code></pre>
  
  <p>but it doesn't look very well. Are there any better options?</p>