[Tutor] Strange Appending

mdcooper mdcooper at uvic.ca
Thu Dec 2 23:08:41 CET 2004


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]]


Can anyone help?

thanks,

Matthew (mdcooper at uvic dot ca)




More information about the Tutor mailing list