Generator Comprehensions? was Re: a break for comprehensions

Guido van Rossum guido at zope.com
Tue Jul 31 23:26:35 EDT 2001


> > How about if we combine your ideas:
> > 
> > y = [yield x*2 for x in g()]
> 
> Geeze, that's like, way obvious.  Why didn't I say that in the first place?
> Good stuff is always way obvious.  Nice one Paul :-)
> 
> What do you think Guido?  => CVS?

I don't think so.  Generators are most useful when they do more than
iterate over a pre-existing sequence, so I doubt that this would be a
common pattern.  Also I'm not sure I like overloading of the [...]
brackets, which (to me) very strongly say "real concrete list here".

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




More information about the Python-list mailing list