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

Manuel Alejandro Cerón Estrada ceronman at gmail.com
Sat Dec 8 22:06:40 CET 2007

2007/12/8, Raymond Hettinger <python at rcn.com>:
>...the proposal adds new syntax without adding functionality.

That is indeed the definition of syntactic sugar [1]. Python is full
of that, for example the import statement.

2007/12/8, Paul Svensson <paul at svensson.org>:
> What is the problem that is not solved by iter(()) ?

'yield iter(()).next()'  it's obscure, you can't know its purpose at
first sight. There are other alternatives but none of them seems to be
the "obvious way to do it".

But that is the less important problem. The real problem is that
raising StopIteration is not orthogonal. It is confusing for the
reasons I exposed. Generators are something in the middle between a
language feature and a framework/library. With 'yield break' they will
be completely a language feature.

[1] http://en.wikipedia.org/wiki/Syntactic_sugar


More information about the Python-Dev mailing list