From 54db446de455ebf2b2cc2154a9adf79c9c9b4dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 11 Mar 2020 12:02:11 +0100 Subject: [PATCH] Duck types --- README.md | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ea2e439..d28b3b8 100644 --- a/README.md +++ b/README.md @@ -1093,7 +1093,7 @@ class MyComparable: ```python class MyHashable: def __init__(self, a): - self._a = copy.deepcopy(a) + self._a = a @property def a(self): return self._a diff --git a/index.html b/index.html index 1d59dce..2c1019f 100644 --- a/index.html +++ b/index.html @@ -1041,7 +1041,7 @@ Z = dataclasses.make_dataclass('Z', [That is why Python automatically makes classes unhashable if you only implement eq().
class MyHashable:
     def __init__(self, a):
-        self._a = copy.deepcopy(a)
+        self._a = a
     @property
     def a(self):
         return self._a