Monday, 30 September 2013

python class function with self initialization

class sam:
   
    def __init__(self,a,b):
        self.a=a
        self.b=b

    def sam1(self,d):
        return self.a+self.b+d
       

s=sam(1,2)
z=s.sam1(3)
print z

No comments:

Post a Comment