Browse Source

Duck types

pull/52/head
Jure Šorn 4 years ago
parent
commit
54db446de4
2 changed files with 2 additions and 2 deletions
  1. 2
      README.md
  2. 2
      index.html

2
README.md

@ -1093,7 +1093,7 @@ class MyComparable:
```python ```python
class MyHashable: class MyHashable:
def __init__(self, a): def __init__(self, a):
self._a = copy.deepcopy(a)
self._a = a
@property @property
def a(self): def a(self):
return self._a return self._a

2
index.html

@ -1041,7 +1041,7 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas
<li><strong>That is why Python automatically makes classes unhashable if you only implement eq().</strong></li> <li><strong>That is why Python automatically makes classes unhashable if you only implement eq().</strong></li>
</ul><pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyHashable</span>:</span> </ul><pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyHashable</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> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self, a)</span>:</span>
self._a = copy.deepcopy(a)
self._a = a
<span class="hljs-meta"> @property</span> <span class="hljs-meta"> @property</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">a</span><span class="hljs-params">(self)</span>:</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">a</span><span class="hljs-params">(self)</span>:</span>
<span class="hljs-keyword">return</span> self._a <span class="hljs-keyword">return</span> self._a

Loading…
Cancel
Save