由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - how to assign object rather and 'reference' to a python list?
相关主题
a python question弱问一下
为什么需要定义 = 和 copy ctorreturn value of a python function...
请教C++面试题问问开发ios的,有用C++来组织代码的么?
什么时候需要调用STL container的destructor?FMP 3.0 Mitbbs 首发 — 求建议求反馈
c++的对象管理符合邓小平理论:来料加工,两头在外怎么检测c++ smart pointer的循环引用?
从无虚函数的基类到有虚函数的派生类objects status snapshot怎么做
请教个JAVA的小问题python一问
[合集] C++ question -- how to save objectsC, C++, Java, C#, Objective-C,
相关话题的讨论汇总
话题: list话题: classa话题: object话题: python话题: assign
进入Programming版参与讨论
1 (共1页)
mw
发帖数: 525
1
hi, everyone
i have a python class like this
def classA:
def __init__(self):
#.....
test_list = list()
for i = range (1,10):
test_list.append(classA())
but in the end, all the 10 items in test_list seem point to the same
classA object
how can I have one classA object for each item in the list ?
does any guru got an idea!
thanks a lot!
w****i
发帖数: 964
2
I tried your code and the 10 items in test_list point to 10 different
objects.
Can you describe more details?
r****t
发帖数: 10904
3
His classA may be defined as singleton.
r****t
发帖数: 10904
4
... may have been ...

【在 r****t 的大作中提到】
: His classA may be defined as singleton.
1 (共1页)
进入Programming版参与讨论
相关主题
C, C++, Java, C#, Objective-C,c++的对象管理符合邓小平理论:来料加工,两头在外
You Don’t Know JS: this & Object Prototypes从无虚函数的基类到有虚函数的派生类
array如何get set?请教个JAVA的小问题
Dynamic buffer management question[合集] C++ question -- how to save objects
a python question弱问一下
为什么需要定义 = 和 copy ctorreturn value of a python function...
请教C++面试题问问开发ios的,有用C++来组织代码的么?
什么时候需要调用STL container的destructor?FMP 3.0 Mitbbs 首发 — 求建议求反馈
相关话题的讨论汇总
话题: list话题: classa话题: object话题: python话题: assign