Browse Source

Comparable

pull/45/head
Jure Šorn 5 years ago
parent
commit
4095057831
2 changed files with 2 additions and 2 deletions
  1. 2
      README.md
  2. 2
      index.html

2
README.md

@ -874,7 +874,7 @@ Duck Types
### Comparable
* **If eq() method is not overridden, it returns `'id(self) == id(other)'`, which is the same as `'self is other'`.**
* **That means all objects compare not equal by default.**
* **Only object on the left side of a comparison has eq() called, unless it returns 'NotImplemented', in which case the right object is consulted.**
* **Only left side object has eq() method called, unless it returns 'NotImplemented', in which case the right object is consulted.**
```python
class MyComparable:

2
index.html

@ -779,7 +779,7 @@ creature = Creature()
<ul>
<li><strong>If eq() method is not overridden, it returns <code class="python hljs"><span class="hljs-string">'id(self) == id(other)'</span></code>, which is the same as <code class="python hljs"><span class="hljs-string">'self is other'</span></code>.</strong></li>
<li><strong>That means all objects compare not equal by default.</strong></li>
<li><strong>Only object on the left side of a comparison has eq() called, unless it returns 'NotImplemented', in which case the right object is consulted.</strong></li>
<li><strong>Only left side object has eq() method called, unless it returns 'NotImplemented', in which case the right object is consulted.</strong></li>
</ul>
<pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyComparable</span>:</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self, a)</span>:</span>

Loading…
Cancel
Save