list of objects containing lists of objects
<p>I'm trying to create a list of objects (Elements), where each element contains a list of objects (GaussPoints). The number of GaussPoints per Element can be variable, although in the example below each element has only one GaussPoint for simplicity.</p>

<pre><code>class Element:
    gp = []

class GaussPoint:
    argument = 0


k = 0
elements = []
for ele in xrange(4):
    k = k+1
    anEle = Element()

    aGP = GaussPoint()
    aGP.argument = k
    print k

    elements.append(anEle)

    elements[ele].gp.append(aGP)

print "testing the data structure:"
for ele in xrange(4):
    print elements[ele].gp[0].argument
</code></pre>

<p>The output is:</p>

<pre><code>1
2
3
4
testing the data structure:
1
1
1
1
</code></pre>

<p>What I'm expecting would be:</p>

<pre><code>1
2
3
4
testing the data structure:
1
2
3
4
</code></pre>

<p>Somehow the code doesn't create a new list of GaussPoints for each Element, but appends to the same one.</p>

<p>I'm obviously misunderstanding something quite fundamental about Python. Could anyone please help?</p>
