Append to the same list
<p>I am from a solid C/C++ background, so please bear with me if my question is silly.</p>

<p>Here I have two classes that declared to encapsulate data,</p>

<pre><code>class Node:
    Term = ""
    TermInfo = []
    def __init__(self,S,Info):
        self.Term = S
        self.TermInfo.append(Info)

class TermInfo:
    DocID = 0
    Freq = 0
    def __init__(self,ID,F):
        self.DocID = ID
        self.Freq = F
</code></pre>

<p>and I was trying to manipulate them this way</p>

<pre><code> Info = TermInfo(ID,0)
 node = Node(j,Info)
 Dict[j] = node
</code></pre>

<p>Basically I was trying to construct a dictionary that contains nodes that are made of a string "Term" and a list of "Terminfo", I was expecting that each node has its own copy. However, after I called the three lines twice in a row </p>

<pre><code>Info = TermInfo(ID,0)
node = Node(j,Info)
Dict[j] = node

Info = TermInfo(ID,0)
node = Node(j,Info)
Dict[j] = node
</code></pre>

<p>I was surprised to see that the two lists of "TermInfo" were pointing to the same memory address and the second append() also changed the first list,So how do I make sure each node has its own copy instead of pointing to the same address? Thanks</p>
