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/2007-December/075632.html below:

[Python-Dev] PEP Idea: Syntactic sugar for StopIteration.

[Python-Dev] PEP Idea: Syntactic sugar for StopIteration. [Python-Dev] PEP Idea: Syntactic sugar for StopIteration.Terry Reedy tjreedy at udel.edu
Sat Dec 8 21:59:55 CET 2007
I would prefer plain 'yield' to 'yield break' as a synonym for 'raise 
StopIteration'.
But the raise stands out better visually as an exit point.

The point about the raise not being explicitly caught is not valid since 
any generator could be used in the following code

g = some_gen
try:
    while True:
        process(g.next())
except StopIteration:
    whatever()

where it is caught.  Then under your proposal, there would be a catch 
without a throw ;-(.

If there were a use case for empty generators, then iter() could be made to 
produce one, in analogy with int() returning 0, etc.  But without a use 
case, 'iter()' is much more likely to be a bug and should be flagged as 
such.  In the meanwhile, 'iter(())' is trivial to type.

Terry Jan Reedy



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