title: Comparing two dictionaries and checking how many (key, value) pairs are equal
body: <p>I have two dictionaries, but for simplification, I will take these two:</p>
  
  <pre><code>&gt;&gt;&gt; x = dict(a=1, b=2)
  &gt;&gt;&gt; y = dict(a=2, b=2)
  </code></pre>
  
  <p>Now, I want to compare whether each <code>key, value</code> pair in <code>x</code> has the same corresponding value in <code>y</code>. So I wrote this:</p>
  
  <pre><code>&gt;&gt;&gt; for x_values, y_values in zip(x.iteritems(), y.iteritems()):
          if x_values == y_values:
              print 'Ok', x_values, y_values
          else:
              print 'Not', x_values, y_values
  </code></pre>
  
  <p>And it works since a <code>tuple</code> is returned and then compared for equality.</p>
  
  <p>My questions:</p>
  
  <p>Is this correct? Is there a <em>better</em> way to do this? Better not in speed, I am talking about code elegance.</p>
  
  <p>UPDATE: I forgot to mention that I have to check how many <code>key, value</code> pairs are equal. </p>