blueloveTH 1 an în urmă
părinte
comite
ec4ddc41fb
3 a modificat fișierele cu 13 adăugiri și 2 ștergeri
  1. 5 0
      python/builtins.py
  2. 6 0
      python/cmath.py
  3. 2 2
      python/datetime.py

+ 5 - 0
python/builtins.py

@@ -239,6 +239,11 @@ class set:
         if not isinstance(other, set):
             return NotImplemented
         return len(self ^ other) == 0
+    
+    def __ne__(self, other):
+        if not isinstance(other, set):
+            return NotImplemented
+        return len(self ^ other) != 0
 
     def isdisjoint(self, other):
         return len(self & other) == 0

+ 6 - 0
python/cmath.py

@@ -30,6 +30,12 @@ class complex:
             return self.real == other and self.imag == 0
         return NotImplemented
     
+    def __ne__(self, other):
+        res = self == other
+        if res is NotImplemented:
+            return res
+        return not res
+    
     def __add__(self, other):
         if type(other) is complex:
             return complex(self.real + other.real, self.imag + other.imag)

+ 2 - 2
python/datetime.py

@@ -10,12 +10,12 @@ class timedelta:
         return f"datetime.timedelta(days={self.days}, seconds={self.seconds})"
 
     def __eq__(self, other: 'timedelta') -> bool:
-        if type(other) is not timedelta:
+        if not isinstance(other, timedelta):
             return NotImplemented
         return (self.days, self.seconds) == (other.days, other.seconds)
 
     def __ne__(self, other: 'timedelta') -> bool:
-        if type(other) is not timedelta:
+        if not isinstance(other, timedelta):
             return NotImplemented
         return (self.days, self.seconds) != (other.days, other.seconds)