inheriting from multiple superclasses : Class Inheritance « Class « Python






inheriting from multiple superclasses

 

class A:
    def foo(self):
        print "foo called in A"
        
class B:
    def foo(self):
        print "foo called in B"

    def bar(self):
        print "bar called in B"
        
class C(A,B):
    pass

   
  








Related examples in the same category

1.Use __class__, __bases__ and __dict__ for sub and super classUse __class__, __bases__ and __dict__ for sub and super class
2.Print out class treePrint out class tree
3.Class inheritedClass inherited
4.Inherited methodInherited method
5.Polymorphism: override the function from base class
6.Definition and test function for class Circle which is based on Point class
7.Derived class inheriting from a base class.
8.Multiple Inheritance
9.Use Inheritance to add more features to a class
10.class extending dict type
11.Class inheritance: inherit member variable override functionClass inheritance: inherit member variable override function