Everything in Python is an object
———— Object Oriented————
- Duck type
- Abstract base class
- Search order of class variables and object variables
- Static method, class method, instance method
- Data encapsulation and private attributes
- Object introspection mechanism
- Context manager
- contextlib implements context manager
- Search order of super function
- Application of mixin inheritance pattern
Everything in Python is an object#
Compared with Java, Python's object-oriented approach is more thorough. Turn everything we can see into objects
Functions and classes are also objects and belong to first-class citizens of Python##
- Can assign functions and classes to a variable
- Can be added to the collection object
- Can be passed as a parameter to the function
- Can be used as the return value of a function (the implementation principle of the decorator)
The relationship between type, object and class#
type is a class, but also an object
object is the top-level base class
The relationship between type and object##
Everything inherits object
Common built-in types in Python#
Three characteristics of the object: identity (ie address, use id to get address), type (use type to get type), value
- None (only one globally)
- Value
- Iteration type
- Sequence type
- Mapping (dict)
- Collection: set, frozenset
- Context management type (with statement)
- other