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 i<1000]
> >
> > of course this could be easily rewritten into
> > i=2
> > lst=[]
> > while i<1000:
> >     i**=2
> >     lst.append(i)
>
> That would loop endlessly since you don't increment i.
> 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.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to