Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 54db446

Browse files
committed
Duck types
1 parent 14eff55 commit 54db446

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ class MyComparable:
10931093
```python
10941094
class MyHashable:
10951095
def __init__(self, a):
1096-
self._a = copy.deepcopy(a)
1096+
self._a = a
10971097
@property
10981098
def a(self):
10991099
return self._a

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@
10411041
<li><strong>That is why Python automatically makes classes unhashable if you only implement eq().</strong></li>
10421042
</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>
10431043
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self, a)</span>:</span>
1044-
self._a = copy.deepcopy(a)
1044+
self._a = a
10451045
<span class="hljs-meta"> @property</span>
10461046
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">a</span><span class="hljs-params">(self)</span>:</span>
10471047
<span class="hljs-keyword">return</span> self._a

0 commit comments

Comments
 (0)