Hello!<br><br>I wrote next code.<br>I intended to insert class object to Pool list.<br><br><Code>==========================================<br>import random,copy<br>class Particle:<br> Dimension = 2<br> CurrentPosition = {}
<br> def __init__(self, dimension):<br> self.Dimension = dimension<br> for i in range(self.Dimension):<br> value = random.uniform(0.,1.)<br> self.CurrentPosition[i] = value<br><br>class Group:
<br> Pool = []<br> def __init__(self, size, dimension):<br> for i in range(size):<br> particle = Particle(dimension)<br> print 'particle generated'<br> print particle.CurrentPosition
<br> self.Pool.append(copy.deepcopy(particle))<br> print '\n total Pool'<br><br>group = Group(3, 2)<br><br>for i in group.Pool:<br> print i.CurrentPosition<br>==============================================
<br><br><br>But the result is like follow.<br>It always synchronized with final insertion. What do you think is the problem ?<br><br><br><Results>=======================================<br> $ python test3.py <br>particle generated
<br>{0: 0.70968382903877392, 1: 0.8019162560229226}<br>particle generated<br>{0: 0.76791838585848948, 1: 0.91689882120031052}<br>particle generated<br>{0: 0.32582853916678456, 1: 0.72166384931732286}<br><br> total Pool<br>
{0: 0.32582853916678456, 1: 0.72166384931732286}<br>{0: 0.32582853916678456, 1: 0.72166384931732286}<br>{0: 0.32582853916678456, 1: 0.72166384931732286}<br>==============================================<br><br><br><br>Thank you in advance !
<br clear="all"><br>