On Tue, Oct 9, 2012 at 2:31 PM, Saju M <[email protected]> wrote: > Hi, > > > I have two classes "A" and "B" > > > class A: > def __init__(self, input): > //do something on input > > > > class B(A): > def __init__(self, input): > A.__init__(self, input) > //do something > > > Then, I want to create two new classes "P" and "Q" > > > class P: > def __init__(self, input): > //do something different on input > > > class Q(p): > def __init__(self, input): > P.__init__(self, input) > //do something > > > > In class "Q", I want all the methods defined in class "B", How do it?. > How redesign this class structure. > Note: constructor of class "A" and "B" doing different operations on input. > Note: But functionalities defined in class "B" should come in class "Q".
One way do that is by writing a class BMixin and let both B and Q extend from BMixin. The BMixin class will have the methods that you would like to have in both classes. Anand _______________________________________________ BangPypers mailing list [email protected] http://mail.python.org/mailman/listinfo/bangpypers
