Programming版 - how to assign object rather and 'reference' to a python list? |
|
|
|
|
|
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.
|
|
|
|
|
|
|