A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-October/057126.html below:

[Python-Dev] PEP 342 suggestion: start(), __call__() and unwind_call() methods

[Python-Dev] PEP 342 suggestion: start(), __call__() and unwind_call() methodsGreg Ewing greg.ewing at canterbury.ac.nz
Mon Oct 10 04:43:31 CEST 2005
Guido van Rossum wrote:

> Plus, Piet also remarked that the value is silently ignored
> when the generator is used in a for-loop. ... I'd worry that accepting
 > "return X" would increase the occurrence of bugs caused by someone
 > habitually writing "return X" where they meant "yield X".

Then have for-loops raise an exception if they get a
StopIteration with something other than None as an
argument.

> I'd like to keep StopIteration really lightweight so it doesn't slow
> down its use in other places.

You could leave StopIteration itself alone altogether
and have a subclass StopIterationWithValue for returning
things. This would make the for-loop situation even safer,
since then you could distinguish between falling off the
end of a generator and executing 'return None' inside it.

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+
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