I'm just beginning to learn Python. I'm finding the type system a little hard to understand. I have a number of questions, but primarily and to cut a long story short; The documentation states:
"All data in a Python program is represented by objects ... Every object has an identity, a type and a value."
No problem. But beyond that its not really described what "objects" are. For example the docs don't even cover that these "objects" support a dot operator - from my PoV they could be some in memory data structure not exposed to the user beyond id(), type() etc. However I gather there is some underlying meta object interface similar to that described for the class instance type object in the docs. To work from an example:
If I do this on a class instance "x":
x.__class__.__name__
I get the name of its class. I understand that. The documentation describes the __class__ and __name__ properties of class instances and class type objects. If I do this [].__class__.__name__ I get "list". Similarly int(1).__class__.__name__ gives "int". Its ambiguous to me exactly what is going on under the hood, and I would like clarification. So my questions are:
- Whats the relationship between a type type "objects" and "class instances" type objects?
- Can I assume the ~meta API to in-built type objects is the same as that of "class instance" type objects?
- If so, what is this interface and where is it documented?
- In general, what are "objects" that correspond to built-in types, and how are they implemented?