On Mon, 26 Dec 2011 00:37:22 +1100, Chris Angelico wrote: > On Mon, Dec 26, 2011 at 12:27 AM, Steven D'Aprano > <steve+comp.lang.pyt...@pearwood.info> wrote: >> There's nothing in the above that assumes that other has the same type >> as self. It's just that the type of other is ignored, and the type of >> self always wins. I find that a nice, clear rule: x.intersection(y) >> always returns a point with the same type as x. > > The intersection of DrawableLine and DrawableLine is DrawablePoint. > That's not the same type as either of the inputs. Same if you seek the > intersection of two planes, which is a line - or two spheres, which is a > circle (with possible failure if they don't intersect).
class Line: intersection_kind = Point def intersection(self, other): blah() return self.intersection_kind(a, b) class DrawableLine(Line): intersection_kind = DrawablePoint -- Steven -- http://mail.python.org/mailman/listinfo/python-list