What are Python's type "objects" exactly? -
I'm just starting to learn Python I'm looking for some kind of difficult system to understand, I have many questions , But mainly to reduce and short story; States:
"All data objects in a Python program are represented by ... each object has an identity, a type and a value."
No problem, but beyond that it was not really told that "objects" are for example, even in docs it is not covered that it is " Objects "support a dot operator - from my POV, there may be something in the memory data structure that allows the user to type in
id () ,
type () etc. Although I have gathered some underlying meta object interfaces which are described in the type of object for the docs. To work with example:
If I do a class instance like "x":
x.__ class____________________> I get the name of its class Understand that The document describes the properties of class examples and classes type items of
__ class __ and
__name__ . If I do this
[] .__ class __.__ name___ I get the "list" Similarly
int (1) .__ class_______________ Int ". Running under the hood, and I need clarification. So my questions are:
- What is the relation between the type of object types type objects and class objects?
- Can I assume that the underlying type objects in the Meta API are similar to "Class Insert" type objects?
- If so, what is this interface and where is it the document?
- In general, what are "objects" that correspond to the underlying type, and how are they implemented?
I will answer the first 1,2 question, then 4 if 3: / p>
- "What type of" objects "and" class instances "type objects?"
- "Can I assume ~ Meta API for in-built type objects" class The instance is similar to "typed objects?"
They are similar, and yes, they share a common API. When "objects" or class instances describe "objects" or anything made as type of class or "object" ... they are talking about building exactly the same language.
- "In general," objects are "what are ..."
Object is a basic language feature in Python which features other OOPL features and Supports Behavior. All the Python objects have classified OOPL classes as well. The class hierarchy in Python is the base
object class. Thus all classes are subclasses of
objects class, and all examples of the above "objects" and
object - through legacy.
It first clearly indicates that in Python (2.2 and above) "Type" and "Square" (for all intense purposes) Therefore, "int", and the rest are the so-called manufactured types of classes (which are definitely shown as objects). For example, to make a
x = int (1) call int class (object) to create an int frequency object, x
It is right to say that Python has two types of objects; "Type" objects, or those that represent the type, and "non-type" objects - who do not, but it is equally true that there are two types of integers; Zero, and not zero does not mean: everything in Python is an object with classes since the class creates an type object, so they are all examples of a class named "type". Type object is also an example of type. Note that you can inspect the succession hierarchy of the class by checking the __bses__ attribute of the class object. In all cases it leads to the course of the
object class - of course. See for more information about this.
- "... where is all this documented?"
OK, in fact it is a good question, it should be included in this section, but it is a kind of skimmed. Constructor for object objects, objects (which have been created) are manufactured and documented in a bilintin. Apart from this, nothing has been included in this area.
Comments
Post a Comment