Created
March 18, 2020 05:21
-
-
Save ntuaha/55e52d5845f4221fb4f961329a5321bf to your computer and use it in GitHub Desktop.
使 test==1 and test==2 and test==3 會等於 True 的 python3 version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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