Re: [Tutor] A list in list problem

2006-08-21 Thread Dave S
On Monday 21 August 2006 17:41, Alan Gauld wrote: > a=b=[] > a > > > > [] > > > b > > > > [] > > These are the same list. > > a=[1,2,3] > > But here you create a new list and assign it to a. > > a > > > > [1, 2, 3] > > > b > > > > [] > > So a points to the new list and

Re: [Tutor] A list in list problem

2006-08-21 Thread Alan Gauld
a=b=[] a > [] b > [] These are the same list. a=[1,2,3] But here you create a new list and assign it to a. a > [1, 2, 3] b > [] So a points to the new list and b to the original. > Tinkering some more I think it is the append that did it. Yes, the append adds th

Re: [Tutor] A list in list problem

2006-08-21 Thread Dave S
On Monday 21 August 2006 13:58, János Juhász wrote: > Hi Dave, > > > From: dave s <[EMAIL PROTECTED]> > > Subject: [Tutor] A list in list problem > > To: python tutor > > Message-ID: <[EMAIL PROTECTED]> > > Content-Type: text/plain; charset="

Re: [Tutor] A list in list problem

2006-08-21 Thread Dave S
On Monday 21 August 2006 13:40, Alan Gauld wrote: > > So when I needed to make a list of a list in the following code I > > thought no > > problem ... > > > > > > def CSV_Lines(self, csv, from_, to): > >"""Returns a list of cleaned up lines from csv 'from_' line > > number 'to' line numb

Re: [Tutor] A list in list problem

2006-08-21 Thread János Juhász
Hi Dave, > From: dave s <[EMAIL PROTECTED]> > Subject: [Tutor] A list in list problem > To: python tutor > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain;  charset="us-ascii" > def CSV_Lines(self, csv, from_, to): > ""&quo

Re: [Tutor] A list in list problem

2006-08-21 Thread Alan Gauld
> So when I needed to make a list of a list in the following code I > thought no > problem ... > > > def CSV_Lines(self, csv, from_, to): >"""Returns a list of cleaned up lines from csv 'from_' line > number 'to' line number""" > >clean_line = clean_csv = [] So clean_line is a

Re: [Tutor] A list in list problem

2006-08-21 Thread Dave S
On Monday 21 August 2006 10:59, dave s wrote: Several hours +1 Sometimes it is usefull spelling out my problem in an email - seems to clarify it - maybe when I get to the 'im stuck' I should send an email to myself :) clean_csv.append(clean_line) ... should by clean_csv.append(clean_line[:])

[Tutor] A list in list problem

2006-08-21 Thread dave s
Help :) I have been playing with this for several hours & am totally stuck ! I am happy with the following ... >>> a=[1,2,3] >>> b=[5,6,7] >>> a [1, 2, 3] >>> b [5, 6, 7] >>> g=[] >>> g [] >>> g.append(a) >>> g [[1, 2, 3]] >>> g.append(b) >>> g [[1, 2, 3], [5, 6, 7]] >>> So when I needed to ma