[Python-Dev] iterator API in Py3.0

Guido van Rossum guido at python.org
Tue Mar 7 06:25:10 CET 2006


On 3/6/06, Michael Hoffman <hoffman at ebi.ac.uk> wrote:
> Another nice thing about having a next() built-in is that it makes
> getting the first item of a generator expression a lot more elegant,
> IMHO.
>
> I think this:
>
> next(item for item in items if item > 3)
>
> is a lot clearer than this:
>
> (item for item in items if item > 3).next()
>
> or alternatives that would break this into multiple statements.

Why is putting everything on a single line considered elegant?

--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list