OO Python Week1
Object:
Contains: Code and data
Key aspect: break problem into small understandable parts
Class/Method/Instances dir()
Class - a template Method or Message - A defined capability of a class Field or attribute- A bit of data in a class Object or Instance - A particular instance of a class
“self” is a formal argument that refers to the object itself.
Object Lifecycle
Constructors(usually used) /Destructors(not frequently used)
In object oriented programming, a constructor in a class is a special block of statements called when an object is created
Constructors can have additional parameters
Inheritace
The new class (child) has all the capabilities of the old class (parent) - and then some more -> the ability to take a class and extend it to make a new class
class FootballFan(PartyAnimal): # inheritace
points = 0
def touchdown(self):
self.points = self.points + 7
self.party()
print self.name,"points",self.points
啊按套路week1总是很简单随便介绍了介绍一些定义,正好有一些比较模糊的基础好差可以知道如何用英语描述…什么时候码代码