class my_class:
def __init__(self):
self.var=1
def setparameter(self,txt):
self.txt=txt
objects = [my_class() for i in range(3)] # creates multiple objects here
for obj in objects:
obj.setparameter(5)
Objects are always accessed through pointers of the type 'PyObject *'.
The type 'PyObject' is a structure that only contains the reference
count and the type pointer. The actual memory allocated for an object
contains other data that can only be accessed after casting the
pointer to a pointer to a longer structure type.
我给你一个程序例子,你可以很容易地理解对象是如何存储在列表中的
列表中的对象是类实例的指针。查看其数据结构
请参阅另一个示例这些列表是子列表的指针
列表列表
^{pr2}$你错了,它是一个特定类型的数组。Python列表被实现为对其他Python对象(直接或间接地,内存地址)的引用数组。因为还有很多家务活要做。在
Python列出了对数据的存储引用,而不是数据本身。直接来自python源代码^{} :
如果您需要更详细的信息,源代码中的注释是详细的和描述性的。在
相关问题 更多 >
编程相关推荐