Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Michael Spencer
Daniel Schüle wrote: > Hello NG, > > I am wondering if there were proposals or previous disscussions in this > NG considering using 'while' in comprehension lists > > # pseudo code > i=2 > lst=[i**=2 while i<1000] > You are actually describing two

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Sion Arrowsmith
<[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: >> >>> list(iter(lambda b=[2]:b.append(b[0]**2) or b[0]<1000 and b.pop(0) or >> None, None)) >> [2, 4, 16, 256] >out of curiosity, what stops the iterator ? : iter(o, sentinel) [ ... ] The iterato

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Peter Otten
[EMAIL PROTECTED] wrote: > list(iter(lambda b=[2]:b.append(b[0]**2) or b[0]<1000 and b.pop(0) or >>None, None)) [2, 4, 16, 256] >> > out of curiosity, what stops the iterator ? """ Help on built-in function iter in module __builtin__: iter(...) iter(collection) -> iterator iter(call

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Bengt Richter
On Tue, 06 Dec 2005 15:44:33 +, Steve Holden <[EMAIL PROTECTED]> wrote: >Daniel Schüle wrote: >> hi, >> >> [...] >> >> >>>># pseudo code >>>>i=2 >>>>lst=[i**=2 while i<1000] >>>> >>&g

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread bonono
Bengt Richter wrote: > On 6 Dec 2005 07:41:45 -0800, [EMAIL PROTECTED] wrote: > > > >If one really wants a very messy one-liner, it is possible > > > >import operator > >x=3D[2] > >lst=3Dlist(((operator.setitem(x,0,x[0]**2),x[0])[1] for _ in > >xrange(1000) if x[0] < 1000 or iter([]).next()))

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Steve Holden
Carsten Haese wrote: > On Tue, 2005-12-06 at 10:44, Steve Holden wrote: > >>Daniel Schüle wrote: >> >i=2 >lst=[] >while i<1000: > i**=2 > lst.append(i) > >>>unless I am missing something obvious, I can not see why the loop should >>>not terminate >> >>In that case

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Bengt Richter
On 6 Dec 2005 07:41:45 -0800, [EMAIL PROTECTED] wrote: > >If one really wants a very messy one-liner, it is possible > >import operator >x=3D[2] >lst=3Dlist(((operator.setitem(x,0,x[0]**2),x[0])[1] for _ in >xrange(1000) if x[0] < 1000 or iter([]).next())) > Or >>> list(iter(lambda b=[2]:b.app

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Chris F.A. Johnson
On 2005-12-06, Steve Holden wrote: > Daniel Schüle wrote: >> hi, >> >> [...] >> >> >>>># pseudo code >>>>i=2 >>>>lst=[i**=2 while i<1000] >>>> >>>>of course this could be easily rewritten into >

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Duncan Booth
Steve Holden wrote: lst=[i**=2 while i<1000] of course this could be easily rewritten into i=2 lst=[] while i<1000: i**=2 lst.append(i) >>> ... > Don't you have an interpreter you could run the code in to verify that > it does indeed loop interminably?

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Carsten Haese
On Tue, 2005-12-06 at 10:44, Steve Holden wrote: > Daniel Schüle wrote: > >>>i=2 > >>>lst=[] > >>>while i<1000: > >>>i**=2 > >>>lst.append(i) > >>> > >> > > > > unless I am missing something obvious, I can not see why the loop should > > not terminate > > In that case, kindly explain how

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Steve Holden
Daniel Schüle wrote: > hi, > > [...] > > >>># pseudo code >>>i=2 >>>lst=[i**=2 while i<1000] >>> >>>of course this could be easily rewritten into >>>i=2 >>>lst=[] >>>while i<1000: >>>i**=2

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread bonono
Duncan Booth wrote: > Daniel Schüle wrote: > > > hi, > > > > [...] > > > >>># pseudo code > >>>i=2 > >>>lst=[i**=2 while i<1000] > >>> > >>>of course this could be easily rewritten into > >>>i

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Steven Bethard
Daniel Schüle wrote: > I am wondering if there were proposals or previous disscussions in this > NG considering using 'while' in comprehension lists > > # pseudo code > i=2 > lst=[i**=2 while i<1000] I haven't had much need for anything like this. Can'

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Duncan Booth
Daniel Schüle wrote: > hi, > > [...] > >>># pseudo code >>>i=2 >>>lst=[i**=2 while i<1000] >>> >>>of course this could be easily rewritten into >>>i=2 >>>lst=[] >>>while i<1000: >>> i**=2 &g

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Daniel Schüle
hi, [...] >># pseudo code >>i=2 >>lst=[i**=2 while i<1000] >> >>of course this could be easily rewritten into >>i=2 >>lst=[] >>while i<1000: >> i**=2 >> lst.append(i) >> > > > Neither of these loops would

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread bonono
Daniel Schüle wrote: > D H wrote: > > [EMAIL PROTECTED] wrote: > > > >>> You can use i**=2 for i in range(1000) instead > >> > >> > >> > >> I don't think one can use assignment in list comprehension or generator > >> expression. The limitation is very much like lambda. > >> > > > > i**2 > > lst=[i

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Daniel Schüle
D H wrote: > [EMAIL PROTECTED] wrote: > >>> You can use i**=2 for i in range(1000) instead >> >> >> >> I don't think one can use assignment in list comprehension or generator >> expression. The limitation is very much like lambda. >> > > i**2 lst=[i**2 for i in range(1000)] you will get a list

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Duncan Booth
Daniel Schüle wrote: > I am wondering if there were proposals or previous disscussions in this > NG considering using 'while' in comprehension lists > > # pseudo code > i=2 > lst=[i**=2 while i<1000] > > of course this could be easily rewritten into > i

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread D H
[EMAIL PROTECTED] wrote: >>You can use i**=2 for i in range(1000) instead > > > I don't think one can use assignment in list comprehension or generator > expression. The limitation is very much like lambda. > i**2 -- http://mail.python.org/mailman/listinfo/python-list

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread bonono
D H wrote: > Daniel Schüle wrote: > > Hello NG, > > > > I am wondering if there were proposals or previous disscussions in this > > NG considering using 'while' in comprehension lists > > > > # pseudo code > > i=2 > > lst=[i**=2 while

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread D H
Daniel Schüle wrote: > Hello NG, > > I am wondering if there were proposals or previous disscussions in this > NG considering using 'while' in comprehension lists > > # pseudo code > i=2 > lst=[i**=2 while i<1000] > > of course this could be easily r

i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Daniel Schüle
Hello NG, I am wondering if there were proposals or previous disscussions in this NG considering using 'while' in comprehension lists # pseudo code i=2 lst=[i**=2 while i<1000] of course this could be easily rewritten into i=2 lst=[] while i<1000: i**=2 lst.appe