Re: Append to python List

2013-05-11 Thread Jussi Piitulainen
Chris Angelico writes: > On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen wrote: > > 8 Dihedral writes: > > > >> This is just the handy style for a non-critical loop. > >> In a critical loop, the number of the total operation counts > >> does matter in the execution speed. > > > > Do you use

Re: Append to python List

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 12:29 PM, 8 Dihedral wrote: > Chris Angelico於 2013年5月12日星期日UTC+8上午12時00分44秒寫道: >> Most humans would get defensive, or at >> least protest, if treated as bots; Dihedral never has, despite being >> referred to in this way a number of times. >> >> ChrisA > > Don't you get

Re: Append to python List

2013-05-11 Thread 88888 Dihedral
Chris Angelico於 2013年5月12日星期日UTC+8上午12時00分44秒寫道: > On Sun, May 12, 2013 at 1:47 AM, Anssi Saari wrote: > > > Chris Angelico writes: > > > > > >> On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen > > >> wrote: > > >>> 8 Dihedral writes: > > >>> > > This is just the handy style for

Re: Append to python List

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 1:47 AM, Anssi Saari wrote: > Chris Angelico writes: > >> On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen >> wrote: >>> 8 Dihedral writes: >>> This is just the handy style for a non-critical loop. In a critical loop, the number of the total operation coun

Re: Append to python List

2013-05-11 Thread Anssi Saari
Chris Angelico writes: > On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen > wrote: >> 8 Dihedral writes: >> >>> This is just the handy style for a non-critical loop. >>> In a critical loop, the number of the total operation counts >>> does matter in the execution speed. >> >> Do you use sp

Re: Append to python List

2013-05-11 Thread Chris Angelico
On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen wrote: > 8 Dihedral writes: > >> This is just the handy style for a non-critical loop. >> In a critical loop, the number of the total operation counts >> does matter in the execution speed. > > Do you use speed often? Dihedral is a bot. Quite

Re: Append to python List

2013-05-10 Thread 88888 Dihedral
Jussi Piitulainen於 2013年5月9日星期四UTC+8下午7時30分05秒寫道: > 8 Dihedral writes: > > > > > This is just the handy style for a non-critical loop. > > > In a critical loop, the number of the total operation counts > > > does matter in the execution speed. > > > > Do you use speed often? There i

Re: Append to python List

2013-05-09 Thread Jussi Piitulainen
8 Dihedral writes: > This is just the handy style for a non-critical loop. > In a critical loop, the number of the total operation counts > does matter in the execution speed. Do you use speed often? -- http://mail.python.org/mailman/listinfo/python-list

Re: Append to python List

2013-05-09 Thread 88888 Dihedral
Jussi Piitulainen於 2013年5月9日星期四UTC+8下午2時55分20秒寫道: > RAHUL RAJ writes: > > > > > Checkout the following code: > > > > > > sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y] > > > output=[] > > > output=[x for x in sample2 if x not in output] > > > > > > the output I get

Re: Append to python List

2013-05-09 Thread Steven D'Aprano
On Thu, 09 May 2013 01:18:51 -0700, RAHUL RAJ wrote: > Then what about this code part? What about it? > [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y] > > and the following code part: > > for x in [1,2,3]: > for y in [3,1,4]: > if x != y: > combs.append((x, y)) Apart from

Re: Append to python List

2013-05-09 Thread RAHUL RAJ
I'm getting same output for both code parts, why not for th code parts in question? On Thursday, May 9, 2013 1:48:51 PM UTC+5:30, RAHUL RAJ wrote: > Then what about this code part? > > > > [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y] > > > > and the following code part: > > > > f

Re: Append to python List

2013-05-09 Thread RAHUL RAJ
Then what about this code part? [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y] and the following code part: for x in [1,2,3]: for y in [3,1,4]: if x != y: combs.append((x, y)) On Thursday, May 9, 2013 12:24:24 PM UTC+5:30, Gary Herron wrote: > On 05/08/2013 11:36 PM, RAHUL RA

Re: Append to python List

2013-05-09 Thread Chris Angelico
On Thu, May 9, 2013 at 4:36 PM, RAHUL RAJ wrote: > output=[x for x in sample2 if x not in output] > > output=[] > for x in sample2: > if x not in output: > output.append(x) The first one constructs a list, then points the name 'output' at it. The second one builds up a list, with 'output'

Re: Append to python List

2013-05-09 Thread Gary Herron
On 05/08/2013 11:36 PM, RAHUL RAJ wrote: Checkout the following code: sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y] output=[] output=[x for x in sample2 if x not in output] This statement is not doing what you expect. It is not building a list in the variable named outpu

Re: Append to python List

2013-05-09 Thread Jussi Piitulainen
RAHUL RAJ writes: > Checkout the following code: > > sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y] > output=[] > output=[x for x in sample2 if x not in output] > > the output I get is > 3 4 5 6 7 8 9 10 3 5 6 7 8 9 10 11 4 5 7 8 9 10 11 12 5 6 7 9 10 11 > 12 13 6 7 8 9 11

Append to python List

2013-05-08 Thread RAHUL RAJ
Checkout the following code: sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y] output=[] output=[x for x in sample2 if x not in output] the output I get is 3 4 5 6 7 8 9 10 3 5 6 7 8 9 10 11 4 5 7 8 9 10 11 12 5 6 7 9 10 11 12 13 6 7 8 9 11 12 13 14 7 8 9 10 11 13 14 15 8 9 10