mdcooper wrote:
Hello,

I am trying to append a list to another list, but everytime I do, the new parent list has a new child list, but all the other lists have become the same as the new child list.

Code:


self._f.write(str(self.residue.atoms[int(t[0])-1].element) + ' ') for m in t: self._f.write(str(m)+' ') self._f.write('\n')

            self.a.append(t) # WHY DOES THIS NOT WORK?????
            print self.a

Output:

[[1, 234, 543]]
[[1, 234, 548], [1, 234, 548]]
[[1, 234, 59], [1, 234, 59], [1, 234, 59]]
[[1, 237, 543], [1, 237, 543], [1, 237, 543], [1, 237, 543]]


I'm guessing what you mean is:

    for m in t:
        self....          # misc filewriting
        self.a.append(m)  # appending *items* of t
    print self.a

See if that little difference works.

Anna
_______________________________________________
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to