In Python, is there a good "magic method" to represent object similarity?
<p>I want instances of my custom class to be able to compare themselves to one another for similarity. This is different than the <code>__cmp__</code> method, which is used for determining the sorting order of objects.</p>

<p>Is there an magic method that makes sense for this? Is there any standard syntax for doing this?</p>

<p>How I imagine this could look:</p>

<pre><code>&gt;&gt;&gt; x = CustomClass("abc")
&gt;&gt;&gt; y = CustomClass("abd")
&gt;&gt;&gt; z = CustomClass("xyz")
&gt;&gt;&gt; x.__&lt;???&gt;__(y)
0.75
&gt;&gt;&gt; x &lt;?&gt; y
0.75
&gt;&gt;&gt; x.__&lt;???&gt;__(z)
0.0
&gt;&gt;&gt; x &lt;?&gt; z
0.0
</code></pre>

<p>Where <code>&lt;???&gt;</code> is the magic method name and <code>&lt;?&gt;</code> is the operator.</p>
