One, homework
Points
1 encapsulation, objects nested within objects
2 Pickle,load: Remember, be sure to import related classes
Two previous sections Review and supplement
Object-Oriented Basics:
1 relationship of classes and objects
23 Major features:
Packaging
Inherited
Object-oriented three major features:
3 polymorphic
def func (ARG):
Print (ARG)
Func (1)
Func (' Alex ')
Func ([11,22,33])
C#/java
def func (int arg):
Print (ARG)
Func (123)
Func ("Alex") #报错
Look at the picture
Three members in object-oriented
Field
Static fields
Normal field
PS: Static field code is loaded when it has been created
Class Foo:
#字段 (static field)
CC = 123
def __init__ (self):
#字段 (normal field) stored in the object
Self.name = ' Alex '
Def show (self):
Print (Self.name)
#一般情况: Access your own fields
#规则:
#普通字段只能对象访问
#静态字段用类访问 (Access is available when last resort)
Method
All methods belong to the class
Normal method, called by the object to execute (method belongs to class) at least one self
static method, the parameter is optional above add a @staticmethod can be executed by the class call (no need to use the object to call)
Class method, the special form of a static method must have the parameter CLS--"represents the class name
Property
A nondescript thing.
A form of writing with a method, with a field access form
Four member modifiers
Five Special members
__init__
__doc__
__call__
__setitem__
Six object-oriented others:
-Isinstance
-Issubclass
-Inheritance 2.7
Application
Custom types, supplementing dictionaries, ordered dictionaries
Extension of the source code
Seven Exception handling:
A single case model of eight design patterns
Class method
Static methods
The Day8 of Python