This commit is contained in:
blueloveTH 2024-08-13 12:57:40 +08:00
parent 0572a8f66b
commit ec4ddc41fb
3 changed files with 13 additions and 2 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)