specify any necessary parameters to the __init__() function : Constructor : Class PYTHON TUTORIALS


PYTHON TUTORIALS » Class » Constructor »

 

specify any necessary parameters to the __init__() function


class testClass(object):
    print "Creating New Classn"
    number=5
    def __init__(self, string):
        self.string = string
    def printClass(self):
        print "Number = %d"% self.number
        print "String = %s"% self.string

tc = testClass("Five")
tc.printClass()
tc.number = 10
tc.string = "Ten"
tc.printClass()



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Class
» Constructor