A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2009-January/085231.html below:

Add a "while" clause to generator expressions

[Python-Dev] PEP 3142: Add a "while" clause to generator expressions [Python-Dev] PEP 3142: Add a "while" clause to generator expressionspython-3000 at udmvt.ru python-3000 at udmvt.ru
Tue Jan 20 15:18:24 CET 2009
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
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4