Pages

Monday, 22 February 2016

Over-riding in Python

# Write A Program To Show Overriding With Super Function….
# Set Your font type as Courier

class A(object) :
    def __init__(self,a) :
        self.a=a
        print "A's __init__"
    def method1(self) :
        print "A's method1 : a is",self.a
class B(A) :
    def __init__(self,b,a) :
        self.b=b
        print "B's __init__"
        super(B,self).__init__(a)
    def method1(self) :
        print "B's method1 : b is",self.b
        super(B,self).method1()
obj1=B(17,22)

obj1.method1()