title: Using Python's list index() method on a list of tuples or objects?
body: <p>Python's list type has an index() method that takes one parameter and returns the index of the first item in the list matching the parameter.  For instance:</p>
  
  <pre><code>&gt;&gt;&gt; some_list = ["apple", "pear", "banana", "grape"]
  &gt;&gt;&gt; some_list.index("pear")
  1
  &gt;&gt;&gt; some_list.index("grape")
  3
  </code></pre>
  
  <p>Is there a graceful (idiomatic) way to extend this to lists of complex objects, like tuples?  Ideally, I'd like to be able to do something like this:</p>
  
  <pre><code>&gt;&gt;&gt; tuple_list = [("pineapple", 5), ("cherry", 7), ("kumquat", 3), ("plum", 11)]
  &gt;&gt;&gt; some_list.getIndexOfTuple(1, 7)
  1
  &gt;&gt;&gt; some_list.getIndexOfTuple(0, "kumquat")
  2
  </code></pre>
  
  <p>getIndexOfTuple() is just a hypothetical method that accepts a sub-index and a value, and then returns the index of the list item with the given value at that sub-index.  I hope</p>
  
  <p>Is there some way to achieve that general result, using list comprehensions or lambas or something "in-line" like that?  I think I could write my own class and method, but I don't want to reinvent the wheel if Python already has a way to do it.</p>