File: class/Workbook/Examples/Lecture7/firstlook.py
class FirstClass: # define a class object
def setdata(self, value): # define class methods
self.data = value # self is the instance
def display(self):
print self.data # self.data: per instance
class SecondClass(FirstClass): # inherits setdata
def display(self): # changes display
print 'Current value = "%s"' % self.data
class ThirdClass(SecondClass): # isa SecondClass
def __init__(self, value): # "ThirdClass(x)"
self.data = value
def __add__(self, other): # "self + other"
return ThirdClass(self.data + other)
def __mul__(self, other):
self.data = self.data * other # "self * other"