Excerpt from: http://www.cnblogs.com/known/archive/2010/09/04/1818231.html
The previously mentioned operational functions and statement blocks are traditional process-oriented programming,
Typically, you write large programs that typically use object-oriented programming
Classes and objects are the main two aspects of object-oriented programming,
Class, create a new type,
Object, which is an instance of the class
Python does not have a value type and a reference type, it sees everything as a class,
class uses the class keyword to create
1. Self
Methods of a class The normal function has only one special difference ———— they must have a first parameter name outside the river,
But when you call this method you do not assign a value to this parameter, Python provides this value, and this particular variable refers to the object itself, according to the Convention its name is self
If you have a class called MyClass and an instance of this class MyObject, when you call this object's method Myobject.method (Arg1, arg2)
This is automatically converted from Python to Myclass.method (MyObject, ARGS1, arg2) ———— that's how self works.
2. Class
3. Methods
A class/object can have a function-like method, and the difference between these methods and functions is just an extra self variable.
Look at the ' self ' parameter
4. __init__ method
I have a peach. The names of many methods in a class have special significance, like __init__, which is similar to constructors.
The __init__ method runs immediately when an object in the class is set up. This method can be used to initialize your object with some of the things you want.
5. Domain
Python has two types of variables for domain classes and variables for objects
Class variables: All objects of a class are shared using only one copy of a class variable, so when an object changes the variables of a class, the change is reflected on all other instances
The variable of the object; Owned by each object, so each object has its own copy of the domain,
6. Inheritance
Python 6 Object-oriented