What is Python dynamic and flexible at all?
All objects in Python, object-oriented, function, class are objects, belong to the citizen
Class Citizen Features
1. You can assign a value to a variable
def name (name= "North Gate Blowing Snow"): print (name) New_name = Namenew_name ()
2. Can be added to the collection object
def name (name= "North Gate Blowing Snow"): print (name) def blog (blog= "http://www.cnblogs.com/2bjiujiu/"): print (blog) Funcs = List () funcs.append (name) funcs.append (blog) for func in Funcs: func ()
3. Can be passed as a parameter to a function
def ask_name (name): name () def name (name= "Beimenchuixue"): print (name) ask_name (name)
4. Can be used as function return value, adorner implementation principle
def ask_name (name): return namedef name (name= "Beimenchuixue"): print (name) Hai = ask_name (name) Hai ()
The relationship between type object class
From an inheritance perspective , Class (list str dict tuple ...) Inherit object, type also inherits object
# Inheritance Relationship # str type Inherits object class print (str.__bases__) # Type type Process object class print (type.__bases__) # object class inherit () print (Object.__bases_ _)
From an instance perspective , "ABC" is an instance of the STR type, and STR is an instance of type, object is an instance of type, and type is an instance of the type itself
Name = "Beimenchuixue" # object class type Instance relationship # name is str instance print (type (name)) # str is the type instance print (Type (str)) # object is type real Example print (Type (object)) # type is its own instance of print (type)
Type > Class > Object
object is constructed from class type, class is constructed by type
The object class is the top-level base class, the base class for all classes, and the type to inherit from this class
type is a class, also an object , inherits the object class, turns itself into its own object, and thus implements all objects in Python.
Gets the type of what the variable is constructed from ()
Gets the base class of the type __bases__
The object base class is ()
The base class is object
The base class of type is object
Python common built-in types
A. Object
1. Identity ID ()
2. Type ()
3. Value corresponding type encapsulates this value
B. value int float complex BOOL
C. None (globally only one) Nonetype type
D. Iteration
E. sequence list tuple str range
F. Mapping dict
G. Set set Frozeset
H. Context management with
I. Other types
1. Module
2. Class and Instance
3. Functions
4. Methods
5. Code
6. Object objects
7. Type
8. Ellipsis type
9. Notimeplementd Class Object
python-All Objects