On 4/25/07, Jeffrey Yasskin <[EMAIL PROTECTED]> wrote: > class MonoidUnderPlus(Abstract):
Is this useful? Just because two things are both Monoid instances doesn't mean I can add them -- they have to be part of the same Monoid. By the time you do assert isinstance(a, MonoidUnderPlus) assert isinstance(b, MonoidUnderPlus) assert isinstance(a, b.__class__) or isinstance(b, a.__class__) I'm not sure how much you've really saved. > **Open issue:** Do we want to give people a choice of which of the > following to define, or should we pick one arbitrarily?:: > def __neg__(self): > """Must define this or __sub__().""" > return self.zero() - self > def __sub__(self, other): > """Must define this or __neg__().""" > return self + -other Probably better to pick one; then it is clear that they have to override something, and there won't be as many accidental infinite loops. If they really want to define the other, they can just do def __neg__(self): super(_this_class__, self).__neg__() The decorator doesn't know it isn't a real override. -jJ _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com