Could you post an actual code example of what you are trying to accomplish? If so, we might be able to come up with some alternatives. But I can't
Patrick writes - think
of a solution without having a bit more detail to think about.
Well say I have a Point class which basically defines a drawing method, and keyword args like "color", and "pointsize" to control appearance. I am working in 3d space. A point defined as an intersection can be defined - let's say - by a plane and a line (or a line and a plane) or two lines (if the lines are coplanar). Where I am now in Python is two separate classes: PlaneIntersection(plane, line, **kw) #argument order therefore significant and LineIntersection(line,line,**kw) In Java, Intesection will behave on the basis of the signature of constructor: I can do something significantly more verbose, but effectively akin to: Intersection(Point): def __init__(*args,**kws): Point.__init__(**kw) (initialize class attributes here) def update(self): (test for existence of intersection and update position of point here) and so where "plane" is a Plane instance "line" is a Line instance Intersection(plane,line) Intesection(line,plane) Intersection(line,line) could all work appropriately without too much todo. Now I think I understand it is mostly Python's dynamic nature that makes this kind of facility difficult (impossible?) to implement as a built_in language feature. And I think I understand the possiblities, at least in general, of a lot of isinstance or type testing of *args - but its ugly, and error-prone - at least, that is, up until the point at which the rest of the design is sufficiently stabilized so that I know *exactly* what it is I want to be testing for and am not expecting any more changes to be coming down the pike. Seems to be the nature of my approach, that I never quite get to that point. So, I am beginning to try to digest the meaning and significance of "multimethods" - for which there are Python modules. I guess then my question, which I am pursuing, is what are multimethods, and how might they relate to the issue I am trying to deal with? Art