For loop comprehensions
Ian Kelly
ian.g.kelly at gmail.com
Fri Feb 11 18:59:52 EST 2011
On Fri, Feb 11, 2011 at 4:47 PM, Westley MartÃnez <anikom15 at gmail.com> wrote:
> No, too confusing. Then people'll want compound loops e.g.:
>
> for a in b if c while d else return x:
> print('Ha ha I'm so clever!')
I've yet to see anybody arguing for while loops to be nested like
that, but we already allow nested for loops in comprehensions and
generator expressions:
[(x, y) for x in a for y in b if c(y)]
Why not allow the same thing in for-loop conditions? I think that
anything that makes the language syntax more consistent is good.
Cheers,
Ian
More information about the Python-list
mailing list