[Python-Dev] accumulator display syntax

Guido van Rossum guido at python.org
Fri Oct 17 12:10:45 EDT 2003


> (yield x*2 for x in foo)
> 
> or maybe:
> 
> (yield: x*2 for x in foo)
> 
> would "yield" better visibility that this is a value that *does*
> something (like lambda).  Or perhaps without the parentheses, but I
> think they're better for clarity, and I'd add them in practice even
> if they weren't required.

Both look decent to me, and in fact the first is what I was thinking
of this morning in the shower. :-)

> The main problem with a gencomp syntax is that some people are going
> to use it for everything whether they need it or not, even when they
> have a small list and the frame overhead for the generator is going
> to make it slower.  So it almost wants to be a really awkward ugly
> thing in order to discourage them...  but then again, that way lies
> Ruby.  :)

Actually, that's also Python's philosophy, if you turn it around: only
things that can be done efficiently should look cute...

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



More information about the Python-Dev mailing list