Am 07.04.2012 14:23 schrieb andrew cooke:
class IntVar(object):
def __init__(self, value=None):
if value is not None: value = int(value)
self.value = value
def setter(self):
def wrapper(stream_in, thunk):
self.value = thunk()
return self.value
return wrapper
def __int__(self):
return self.value
def __lt__(self, other):
return self.value< other
def __eq__(self, other):
return self.value == other
def __hash__(self):
return hash(self.value)
so what am i missing?
If I don't confuse things, I think you are missing a __gt__() in your
IntVar() class.
This is because first, a '2 < three' is tried with 2.__lt__(three). As
this fails due to the used types, it is reversed: 'three > 2' is
equivalent. As your three doesn't have a __gt__(), three.__gt__(2) fails
as well.
Thomas
--
http://mail.python.org/mailman/listinfo/python-list