For loop comprehensions

2011-02-11 Thread Benjamin S Wolf
It occurred to me as I was writing a for loop that I would like to write it in generator comprehension syntax, eg. for a in b if c: rather than using one of the more verbose but allowable syntaxes: for a in (x for x in b if c): for a in b: if not c: continue Python 3.1 does not suppo

Re: For loop comprehensions

2011-02-12 Thread Benjamin S Wolf
On Feb 11, 3:47 pm, Westley Martínez 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!') On Feb 11, 6:34 pm, Steven D'Aprano wrote: > There's nothing wrong with writing > > for x in iterable: >     if