Python object and type, pythonobjecttype
1. Excerpt from Python Documentation 3.5.2
ObjectsAre Python's own action for data. all data in a Python program is represented by objects or by relations between objects. (In a sense, and in conformance to Von norann's model of a "stored program computer," code is also represented by objects .)
The object is Python's data abstraction. All data in a Python program is expressed by the relationship between objects or objects. (In a sense, and in line with the model of von noriman's "storage program computer", the Code is also represented by objects ).
Every object has an identity, a type and a value. An object'sIdentityNever changes once it has been created; you may think of it as the object's address in memory.'is'Operator compares the identity of two objects;id()Function returns an integer representing its identity.
Each object has an identifier, a type, and a value. The identity of an object will not change once it is created; you can regard it as the object address in the memory. The 'is operator compares the identifiers of two objects. The id () function returns an integer that represents the identity.
An object's type determines the operations that the object supports (e.g., "does it have a length ?") And also defines the possible values for objects of that type. The type () function returns an object's type (which is an object itself). Like its identity, an object'sTypeIs also unchangeable.
The object type determines the operations supported by the object (for example, "does it have a length ?"), It also defines the possible values of this type of object. The type () function returns the type of an object (it is an object itself ). Like its identity, the object type cannot be changed.
2. Explanation of Pyhtml:
Object:
class object The most base type
Type:
class type(object) type(object_or_name, bases, dict) type(object) -> the object's type type(name, bases, dict) -> a new type
From the above three figures, we can see that the object obeject is the most basic type and is a holistic abstract concept of data. Compared with object, type is a slightly specific abstract concept. It is specific because it has refined the more specific abstract concepts from object, this is why types such as type (int), type (float), type (str), type (list), type (tuple), and type (set) are all type, this is also why both instance (type, object) and instance (object, type) are True, that is, the type is used as the overall concept of int, float, and other types. So why is issubclass (type, object) True, and issubclass (object, type) Flase? As shown in the second figure, type is a subclass of the object, so the former is True, and the latter is False.
If you look at these problems from a more fundamental perspective, you need to go through Python Documentation --> 3. data Model --> 3.1 Objects, values and types found the cause [Please refer to the official Python standard library]. You can see from the Standard Library:
- Object is the abstraction of data by Python, which is a centralized embodiment of data by Python programs.
- Each object has an identifier, a type, and a value.
- The object type determines the operations supported by the object.
- The values of some objects can be changed. Objects whose values can be changed are called variable objects. Objects whose values cannot be changed after creation are called immutable objects.
Therefore, from the perspective of the overall Python design system, there are objects first, then identifiers, types and values, and then operations on objects, this explains the cause of the result in figure 3.