What's t supposed to be, what are you initialising self.a as, where is
t generated, what is your expected output? What else is happening to
self.a?

Looks like an indentation error to me.

This kind of output 
[[1, 237, 543], [1, 237, 543], [1, 237, 543], [1, 237, 543]]

would only come from 

a loop iterating over the command that appends [1,237,543] several times.

I'd check your logic, logical errors are the hardest.
I use that kind of thing often - 

i.e. 

x=[]
a="Hello 123, How is 456?"
for item in a:
       try:
         w=(int(item))/1
       except TypeError:
            continue
        x.append(item)

print x

['1','2','3','4','5','6']


But yeah, post up all the relevant code please, just not the bit
that's not breaking. I can't see your loop that's writing the wrong
values, or perhaps self.a is getting reinitialized wrong? If you get
my point.


Regards,

Liam Clarke

On Thu, 2 Dec 2004 14:41:03 -0800 (PST), Marilyn Davis
<[EMAIL PROTECTED]> wrote:
> On Thu, 2 Dec 2004, 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?????
> 
> Hi,
> 
> I'm not sure that I understand your question because I don't see all
> the code and I don't know what you hope will happen.  But ...
> 
> append appends the object as a single element.
> 
> Try self.a.extend(t)
> 
> extend attaches the t list to the end of the list.
> 
> Does this give you what you expect?
> 
> Marilyn Davis
> 
> 
> 
> >             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)
> >
> >
> > _______________________________________________
> > Tutor maillist  -  [EMAIL PROTECTED]
> > http://mail.python.org/mailman/listinfo/tutor
> >
> 
> --
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  [EMAIL PROTECTED]
> http://mail.python.org/mailman/listinfo/tutor
> 


-- 
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.
_______________________________________________
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to