Skip to content

Instantly share code, notes, and snippets.

@ntuaha
Created March 18, 2020 05:21
Show Gist options
  • Save ntuaha/55e52d5845f4221fb4f961329a5321bf to your computer and use it in GitHub Desktop.
Save ntuaha/55e52d5845f4221fb4f961329a5321bf to your computer and use it in GitHub Desktop.
使 test==1 and test==2 and test==3 會等於 True 的 python3 version
from functools import total_ordering
@total_ordering
class TEST:
def __init__(self,a):
self.a = a
def __eq__(self, other):
ans = self.a == other
self.a += 1
print(self.a)
return ans
def __lt__(self, other):
ans = self.a <= other
self.a += 1
print(self.a)
return ans
def main():
test = TEST(1)
print(f"test==1 and test==2 and test==3 is {test==1 and test==2 and test==3}")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment