hmmm...doesn't: if n*n < 50 or raise StopIteration()
really mean, "Return an integer in the range 0-99 if n-squared is less than fifty or the statement 'raise StopIteration()' returns True" ? I'm not sure that that will work. On Tue, Jan 20, 2009 at 9:18 AM, <python-3...@udmvt.ru> wrote: > On Mon, Jan 19, 2009 at 10:10:00AM -0500, Gerald Britton wrote: >> Please find below PEP 3142: Add a "while" clause to generator >> expressions. I'm looking for feedback and discussion. >> > ... >> g = (n for n in range(100) while n*n < 50) > > May I suggest you this variant? > > def raiseStopIteration(): > raise StopIteration > > g = (n for n in range(100) if n*n < 50 or raiseStopIteration()) > > Well, there are more characters... > > But it is not using any syntax changes and does not require any approval > to be functional. Yet it is as fast as the proposed variant, does not require > modules and, I hope, will not confuse you or anyone else. > > > -- > Alexey G. Shpagin > _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com