Stefan Behnel wrote: > Allen Peloquin wrote: >> class B >> { >> fun(A x, A y, A z)... >> fun(A1 x, A y, A z)... >> } >> >> class B1 >> { >> fun(A1 x, A y, A z)... >> } >> >> Such that any previous behavior is inherited, but behaves >> polymorphically because of the single function name. > > Try something like this: > > class B(object): > def fun(x,y,z): > if isinstance(x, A1): > return self._fun(x,y,z) > # ... > > def _fun(x,y,z): > # ... > > class B1(B): > def _fun(x,y,z): > # ...
Oh, well, make that: class B(object): def fun(self, x,y,z): if isinstance(x, A1): return self._fun(x,y,z) # ... def _fun(self, x,y,z): # ... class B1(B): def _fun(self, x,y,z): # ... (but you already knew that anyway, didn't you?) Stefan -- http://mail.python.org/mailman/listinfo/python-list