Re: using "*" to make a list of lists with repeated (and independent) elements

2012-09-29 Thread 88888 Dihedral
On Sunday, September 30, 2012 1:19:22 AM UTC+8, Ian wrote: > On Sat, Sep 29, 2012 at 11:01 AM, 8 Dihedral > > wrote: > > > > > > Don't you get it why I avoided the lambda one liner as a functon. > > > > > > I prefer the def way with a name chosen. > > > > Certainly, but the Bresenham l

Re: using "*" to make a list of lists with repeated (and independent) elements

2012-09-29 Thread Chris Angelico
On Sun, Sep 30, 2012 at 3:18 AM, Ian Kelly wrote: > On Sat, Sep 29, 2012 at 11:01 AM, 8 Dihedral > wrote: >> >> Don't you get it why I avoided the lambda one liner as a functon. >> >> I prefer the def way with a name chosen. > > Certainly, but the Bresenham line algorithm is O(n), which is wh

Re: using "*" to make a list of lists with repeated (and independent) elements

2012-09-29 Thread Ian Kelly
On Sat, Sep 29, 2012 at 11:01 AM, 8 Dihedral wrote: > > Don't you get it why I avoided the lambda one liner as a functon. > > I prefer the def way with a name chosen. Certainly, but the Bresenham line algorithm is O(n), which is why it is so superior to quicksort that is O(n log n). Of cours

Re: using "*" to make a list of lists with repeated (and independent) elements

2012-09-29 Thread 88888 Dihedral
On Saturday, September 29, 2012 9:46:22 PM UTC+8, Ramchandra Apte wrote: > On Thursday, 27 September 2012 04:14:42 UTC+5:30, Tim Chase wrote: > > > On 09/26/12 17:28, 8 Dihedral wrote: > > > > > > > 8 Dihedral於 2012年9月27日星期四UTC+8上午6時07分35秒寫道: > > > > > > In these conditions, ho

Re: using "*" to make a list of lists with repeated (and independent) elements

2012-09-29 Thread Ramchandra Apte
On Thursday, 27 September 2012 04:14:42 UTC+5:30, Tim Chase wrote: > On 09/26/12 17:28, 8 Dihedral wrote: > > > 8 Dihedral於 2012年9月27日星期四UTC+8上午6時07分35秒寫道: > > In these conditions, how to make this list [[0,0,0],[0,0,0]] with "*" > > without this behavior? > > >>> >>> a

Re: using "*" to make a list of lists with repeated (and independent) elements

2012-09-27 Thread 88888 Dihedral
Tim Chase於 2012年9月27日星期四UTC+8上午6時44分42秒寫道: > On 09/26/12 17:28, 8 Dihedral wrote: > > > 8 Dihedral於 2012年9月27日星期四UTC+8上午6時07分35秒寫道: > > In these conditions, how to make this list [[0,0,0],[0,0,0]] with "*" > > without this behavior? > > >>> >>> a = [[0]*3 for i in xrange(

Re: using "*" to make a list of lists with repeated (and independent) elements

2012-09-26 Thread 88888 Dihedral
Tim Chase於 2012年9月27日星期四UTC+8上午6時44分42秒寫道: > On 09/26/12 17:28, 8 Dihedral wrote: > > > 8 Dihedral於 2012年9月27日星期四UTC+8上午6時07分35秒寫道: > > In these conditions, how to make this list [[0,0,0],[0,0,0]] with "*" > > without this behavior? > > >>> >>> a = [[0]*3 for i in xrange(

Re: using "*" to make a list of lists with repeated (and independent) elements

2012-09-26 Thread Tim Chase
On 09/26/12 17:28, 8 Dihedral wrote: > 8 Dihedral於 2012年9月27日星期四UTC+8上午6時07分35秒寫道: In these conditions, how to make this list [[0,0,0],[0,0,0]] with "*" without this behavior? >>> >>> a = [[0]*3 for i in xrange(2)] >>> >>> a[0][0]=2 >>> >>> a >>> [[2, 0, 0], [0, 0

Re: using "*" to make a list of lists with repeated (and independent) elements

2012-09-26 Thread 88888 Dihedral
8 Dihedral於 2012年9月27日星期四UTC+8上午6時07分35秒寫道: > Paul Rubin於 2012年9月27日星期四UTC+8上午5時43分58秒寫道: > > > TP writes: > > > > > > > copies a list, he copies in fact the *pointer* to the list > > > > > > > Is it the correct explanation? > > > > > > > > > > > > Yes, that is correct. > >

Re: using "*" to make a list of lists with repeated (and independent) elements

2012-09-26 Thread 88888 Dihedral
Paul Rubin於 2012年9月27日星期四UTC+8上午5時43分58秒寫道: > TP writes: > > > copies a list, he copies in fact the *pointer* to the list > > > Is it the correct explanation? > > > > Yes, that is correct. > > > > > In these conditions, how to make this list [[0,0,0],[0,0,0]] with "*" > > > without

Re: using "*" to make a list of lists with repeated (and independent) elements

2012-09-26 Thread 88888 Dihedral
TP於 2012年9月27日星期四UTC+8上午5時25分04秒寫道: > Hi everybody, > > > > I have tried, naively, to do the following, so as to make lists quickly: > > > > >>> a=[0]*2 > > >>> a > > [0, 0] > > >>> a[0]=3 > > >>> a > > [3, 0] > > > > All is working fine, so I extended the technique to do: > > > >

Re: using "*" to make a list of lists with repeated (and independent) elements

2012-09-26 Thread Paul Rubin
TP writes: > copies a list, he copies in fact the *pointer* to the list > Is it the correct explanation? Yes, that is correct. > In these conditions, how to make this list [[0,0,0],[0,0,0]] with "*" > without this behavior? >>> a = [[0]*3 for i in xrange(2)] >>> a[0][0]=2 >>>

Re: using "*" to make a list of lists with repeated (and independent) elements

2012-09-26 Thread Ian Kelly
On Wed, Sep 26, 2012 at 3:20 PM, TP wrote: > Hi everybody, > > I have tried, naively, to do the following, so as to make lists quickly: > a=[0]*2 a > [0, 0] a[0]=3 a > [3, 0] > > All is working fine, so I extended the technique to do: > a=[[0]*3]*2 a > [[0, 0, 0], [0,

using "*" to make a list of lists with repeated (and independent) elements

2012-09-26 Thread TP
Hi everybody, I have tried, naively, to do the following, so as to make lists quickly: >>> a=[0]*2 >>> a [0, 0] >>> a[0]=3 >>> a [3, 0] All is working fine, so I extended the technique to do: >>> a=[[0]*3]*2 >>> a [[0, 0, 0], [0, 0, 0]] >>> a[0][0]=2 >>> a [[2, 0, 0], [2, 0, 0]] The behavior i