On Dec 15, 2:05 pm, [EMAIL PROTECTED] wrote:
> My reasoning is (I hope) that the container ought to support every
> comparison operation supported by the contained objects. This can be
> ensured by being careful in the implementation.
>
If you're traversing two containers in parallel to compare them then
you could do something like:
class LarchTree:
...
def compare(self, other, cmp):
# Same code as your original __gt__ but
# with cmp(x, y) instead of x > y
def __lt__(self, other):
return self.compare(other, operator.lt)
def __gt__(self, other):
return self.compare(other, operator.gt)
# etc...
This way the LarchTree object doesn't interpret the comparison
operators, just passes them on to its elements.
--
Arnaud
--
http://mail.python.org/mailman/listinfo/python-list