notes:
Object Oriented Introduction
All things in the world can be classified
All things in the world are objects
as long as the object, it must belong to a certain category
as long as the object, there must be attributes
attribute class, Object
Package
Inheritance
# python3.0 Version Breadth First (classic class, Modern Class) D-b,c-a
# python2.0 Version Classic class depth first d-b-a,d-c-a
# New class breadth First
polymorphic
one interface, multiple implementations (interface reuse)
syntax properties, methods,
Constructor _init_
destructors are automatically executed when an instance is disposed, destroyed, and often used to do some finishing work, such as closing some database connections, opening some temporary files _del_
private methods, private properties
instantiation: The process of turning a class into a concrete object
class variables, instance variables
use of class variables: Common attributes, saving overhead (memory)
static method:
Only nominal collation management, in fact, in a static method cannot access any of the properties of the class or instance
Class method:
Only class variables can be accessed and instance variables cannot be accessed
Property Method:
Turn a method into a static property
To illustrate:
1 classDog:2 def __init__(self,name):3Self.name=name4 5 defBulk (self):6 Print("%s: Wang Bark!!!"%self.name)7D1=dog ("Golden Three Fat")8D2=dog ("Wang")9D3=dog ("Lao Wang")Ten One D1.bulk () A D2.bulk () -D3.bulk ()
Python Basics-Class