title: objects as keys in python dictionaries
body: <p>I'm trying to use an object as a key in a python dictionary, but it's behaving in a way that I can't quite understand.</p>
  
  <p>First I create a dictionary with my object as the key:</p>
  
  <pre><code>package_disseminators = {
    ContentType("application", "zip", "http://other/property") : "one",
    ContentType("application", "zip") : "two"
  }
  </code></pre>
  
  <p>Now create another object that is "the same" as one which is a key.  </p>
  
  <pre><code>content_type = ContentType("application", "zip", "http://other/property")
  </code></pre>
  
  <p>I have given the ContentType object custom <code>__eq__</code> and custom <code>__str__</code> methods, such that the <code>__eq__</code> method compares the <code>__str__</code> values.</p>
  
  <p>Now, some interactive python:</p>
  
  <pre><code>&gt;&gt;&gt; for key in package_disseminators:
  ...     if key == content_type:
  ...             print "match"
  ...     else:
  ...             print "no match"
  ... 
  no match
  match
  
  &gt;&gt;&gt; content_type in package_disseminators.keys()
  True
  </code></pre>
  
  <p>Ok, so it looks like my object is definitely being identified properly as a key, so:</p>
  
  <pre><code>&gt;&gt;&gt; package_disseminators[content_type]
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  KeyError: (&amp; (type="application/zip") (packaging="http://other/property") )
  </code></pre>
  
  <p>Er ... ok?  So content_type is in the package_disseminators.keys() list, but isn't a key?</p>
  
  <pre><code>&gt;&gt;&gt; package_disseminators.has_key(content_type)
  False
  </code></pre>
  
  <p>Apparently not.</p>
  
  <p>I presume that the comparison process that Python uses to determin equality differs between a straight "in" statement on a list and actually looking up a key in a dict, but I don't know how.  Any tips or insights?</p>