title: testing for equality using itemgetter
body: <pre><code>from operator import itemgetter
  from itertools import takewhile
  
  xs = [ ('foo',1), ('bar',1), ('baz',2) ]
  </code></pre>
  
  <p><code>xs</code> is sorted on the second item - there are no more <code>1</code>s after <code>'bar'</code>.</p>
  
  <pre><code>def item_map(xs):
      getcount = itemgetter(1)
      return list(map(getcount,xs))
  
  print(item_map(xs))
  &gt;&gt;&gt; [1, 1, 2]
  </code></pre>
  
  <p>returns a list of the second element of every tuple. </p>
  
  <pre><code>def item_take(xs):   
      return list(takewhile(lambda x: x[1] == 1, xs))
  
  print(item_take(xs))
  [('foo', 1), ('bar', 1)]
  </code></pre>
  
  <p>returns the tuples that have a second element that == 1.</p>
  
  <pre><code>def could_this_work(xs):
      match = itemgetter(1) == 1 
      return list(takewhile(match, xs))
  
  print(could_this_work(xs))
  TypeError: 'bool' object is not callable
  </code></pre>
  
  <p>does not return the tuples that have a second element that == 1</p>
  
  <p>Is there a way to use <code>itemgetter</code> in place of the lambda? Or can <code>itemgetter</code> not be used in this way?</p>
  
  <p>EDIT. <code>takewhile</code> is being used for a reason. I understand what it does. This function is going to be used on a sorted list. I appreciate that the tuples are backwards for this, but the code that I have used it correct for what I want and expect.  </p>