title: How can I negate a search on a list using this iterable function?
body: <p>I wrote a python function to search through an iterable:</p>
  
  <pre><code>def iter_search(iterable, **search):
      for item in iterable:
          # Assume we will find something to yield
          yield_me=True
  
          # Cycle through keys that exist in the search and item
          for key in item.viewkeys() &amp; search:
              if item[key] is not None:
                  if item[key] != search[key]:
                      # Key didn't match, don't yield this item
                      yield_me = False
          if yield_me:
              yield item
  </code></pre>
  
  <p>Works great, in that my search 'key' can be any number of dictionary key value pairs:</p>
  
  <pre><code>new_iterable = iter_search(iter, ** { 'C' : 'US', 'Sex' : 'm' })
  </code></pre>
  
  <p>Now, I'm trying to negate a search, so I tried:</p>
  
  <pre><code>def iter_search(iterable, **search):
      for item in iterable:
          yield_me=True
          for key in item.viewkeys() &amp; search:
              if item[key] is not None:
                  if search[key][0] == '!':
                      if item[key] == search[key][1:]:
                          yield_me = False
                  else:
                      if item[key] != search[key]:
                          yield_me = False
          if yield_me:
              yield item
  </code></pre>
  
  <p>But now, it yields nothing when I include the my negation character ('!'):</p>
  
  <pre><code>    new_iterable = iter_search(iter, ** { 'C' : '!US', 'Sex' : 'm' })
  </code></pre>
  
  <p>I'm missing something simple.  What?</p>
  
  <p><em><strong>EDIT</em></strong> I was testing the wrong version of my code!  The above works just fine.</p>