""" Python does polymorphism """ class A: # base class declartion def __init__( self ): # constructor self.index = 0 # define and initialize variable def doIncrement( self ): # manipulator self.index += 1 class B( A ): # subclass declaration def doIncrement( self ): # function replacement self.index += 3 class C( A ): # another subclass def doIncrement( self ): self.index += 7 a = A() a.doIncrement() print( "a index %d" % ( a.index ) ) b = B() b.doIncrement() print( "b index %d" % ( b.index ) ) c = C() c.doIncrement() print( "c index %d" % ( c.index ) )