[New-bugs-announce] [issue6113] Dupicate instances of classes in list

Matthew report at bugs.python.org
Tue May 26 10:54:03 CEST 2009


New submission from Matthew <matthew.baynham at gmail.com>:

What I intended was...
I create a list of DIFFERENT instances of the same class, I wanted them
to be different instances, with different values for the properties,
stressing the word "DIFFERENT".

What I originally did was...
The __init__ assigns default values for the properties (eg, iId = 0, and
sName = ''), then I would change to properties before adding it to the
list.  However, the list will contain the right number of elements, but
every element is the same instance of the class.

I resolved this by...
If I change __init__ such that I'm passing it parameters with values to
assign to the properties.  And then adding the instances of the class to
the list.  Then each element in the list is a different instance.  And
this made everything work.

----------
components: Windows
messages: 88340
nosy: mbaynham
severity: normal
status: open
title: Dupicate instances of classes in list
versions: Python 2.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6113>
_______________________________________


More information about the New-bugs-announce mailing list