From python-list Tue Nov 21 22:53:04 2006 From: Sorin Schwimmer Date: Tue, 21 Nov 2006 22:53:04 +0000 To: python-list Subject: Help! I need a list, not a pointer to it Message-Id: <20061121225304.67695.qmail () web56001 ! mail ! re3 ! yahoo ! com> X-MARC-Message: https://marc.info/?l=python-list&m=116414961101433 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============0243679395==" --===============0243679395== Content-Type: multipart/alternative; boundary="0-1706560907-1164149584=:67639" --0-1706560907-1164149584=:67639 Content-Type: text/plain; charset=ascii Content-Transfer-Encoding: quoted-printable Hi All,=0A=0AThe following code:=0A=0A=0Ar=3D3=0Ac=3D1=0Asolutions=3D= []=0Amatrix=3D[[1.0], [0], [0]]=0Aj=3D0=0Awhile j=0A=0Agives:= =0A[[0], [1.0], [0]]=0A[[0], [0], [1.0]]=0A[[1.0], [0], [0]]=0A[[[1.0], [0]= , [0]], [[1.0], [0], [0]], [[1.0], [0], [0]]]=0A(i.e. the last value of mat= rix, three times)=0A=0AHow can I end up with:=0A[[0], [1.0], [0]]=0A[[0], [= 0], [1.0]]=0A[[1.0], [0], [0]]=0A[[[0], [1.0], [0]], [[0], [0], [1.0]], [[1= .0], [0], [0]]]=0A(i.e. each value of matrix)?=0A=0AI'm on Python 2.4.1, un= der Linux.=0A=0AThanks,=0ASorin=0A=0A=0A=0A=0A =0A_________________________= ___________________________________________________________=0ASponsored Lin= k=0A=0AOnline degrees - find the right program to advance your career. =0Aw= ww.nextag.com --0-1706560907-1164149584=:67639 Content-Type: text/html; charset=ascii Content-Transfer-Encoding: quoted-printable
Hi All,

The following code:

<code>=
r=3D3
c=3D1
solutions=3D[]
matrix=3D[[1.0], [0], [0]]
j=3D0=
while j<c:
  i=3D0
  j=3D0
  more=3DTrue
=   while more:
    while not matrix[i][j]:
 &= nbsp;    i+=3D1
    i+=3D1
  =   if i=3D=3Dr:
      matrix[0][j]=3Dmatrix= [i-1][j]
      matrix[i-1][j]=3D0
 &nbs= p;    i=3D0
      j+=3D1
&nbs= p;     if j=3D=3Dc: more=3DFalse
    = else:
      matrix[i][j]=3Dmatrix[i-1][j]
&n= bsp;     matrix[i-1][j]=3D0
    =   more=3DFalse
  print matrix
  solutions.append(matrix) # same result with matrix[:]
print solutions</code>

gives:
[[0], [1.0], [0]]
[[0], [0], [1.0]]
= [[1.0], [0], [0]]
[[[1.0], [0], [0]], [[1.0], [0], [0]], [[1.0], [0], [0= ]]]
(i.e. the last value of matrix, three times)

How can I end up= with:
[[0], [1.0], [0]]
[[0], [0], [1.0]]
[[1.0], [0], [0]]
[[= [0], [1.0], [0]], [[0], [0], [1.0]], [[1.0], [0], [0]]]
(i.e. each value= of matrix)?

I'm on Python 2.4.1, under Linux.

Thanks,
Sor= in

=0A=0A
Sponsored Link


Mortgage rates near 39yr lows. $4= 20,000 Mortgage for $1,399/mo - =0ACalculate new house pay= ment --0-1706560907-1164149584=:67639-- --===============0243679395== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- http://mail.python.org/mailman/listinfo/python-list --===============0243679395==--