File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -876,7 +876,7 @@ class MyComparable:
876
876
def __eq__ (self , other ):
877
877
if isinstance (other, type (self )):
878
878
return self .a == other.a
879
- return False
879
+ return NotImplemented
880
880
```
881
881
882
882
### Hashable
@@ -894,7 +894,7 @@ class MyHashable:
894
894
def __eq__ (self , other ):
895
895
if isinstance (other, type (self )):
896
896
return self .a == other.a
897
- return False
897
+ return NotImplemented
898
898
def __hash__ (self ):
899
899
return hash (self .a)
900
900
```
Original file line number Diff line number Diff line change @@ -782,7 +782,7 @@ <h3 id="comparable">Comparable</h3>
782
782
< span class ="hljs-function "> < span class ="hljs-keyword "> def</ span > < span class ="hljs-title "> __eq__</ span > < span class ="hljs-params "> (self, other)</ span > :</ span >
783
783
< span class ="hljs-keyword "> if</ span > isinstance(other, type(self)):
784
784
< span class ="hljs-keyword "> return</ span > self.a == other.a
785
- < span class ="hljs-keyword "> return</ span > < span class ="hljs-keyword " > False </ span >
785
+ < span class ="hljs-keyword "> return</ span > < span class ="hljs-built_in " > NotImplemented </ span >
786
786
</ code > </ pre >
787
787
< h3 id ="hashable "> Hashable</ h3 >
788
788
< ul >
@@ -799,7 +799,7 @@ <h3 id="hashable">Hashable</h3>
799
799
< span class ="hljs-function "> < span class ="hljs-keyword "> def</ span > < span class ="hljs-title "> __eq__</ span > < span class ="hljs-params "> (self, other)</ span > :</ span >
800
800
< span class ="hljs-keyword "> if</ span > isinstance(other, type(self)):
801
801
< span class ="hljs-keyword "> return</ span > self.a == other.a
802
- < span class ="hljs-keyword "> return</ span > < span class ="hljs-keyword " > False </ span >
802
+ < span class ="hljs-keyword "> return</ span > < span class ="hljs-built_in " > NotImplemented </ span >
803
803
< span class ="hljs-function "> < span class ="hljs-keyword "> def</ span > < span class ="hljs-title "> __hash__</ span > < span class ="hljs-params "> (self)</ span > :</ span >
804
804
< span class ="hljs-keyword "> return</ span > hash(self.a)
805
805
</ code > </ pre >
You can’t perform that action at this time.
0 commit comments