Classes and Types : Class Definition : Class PYTHON TUTORIALS


PYTHON TUTORIALS » Class » Class Definition »

 

Classes and Types


class Person: 
    def setName(self, name):
        self.name = name 
    def getName(self):
        return self.name 
    def greet(self):
        print "Hello, world! I'm %s." % self.name

foo = Person()
bar = Person()
foo.setName('A')
bar.setName('B')
foo.greet()
bar.greet()
print foo.name 
bar.greet()



Leave a Comment / Note


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


PYTHON TUTORIALS

 Navioo Class
» Class Definition