I want to do something like this:
MyClass > 200 < 400
The class implements the __gt__()
and __lt__()
methods and they both return self
.
class MyClass:
...
def __gt__(self, value):
DoCompareStuff(self, value)
return self
def __lt__(self, value):
DoCompareStuff(self, value)
return self
...
It will do the first evaluation, MyClass > 200
, but never performs the second, MyClass < 400
. It seems like Python is doing something with the return value like making it True
or False
. Is there a way to do what I'm trying to do here?