Generator Comprehensions? was Re: a break for comprehensions
kseehof at neuralintegrator.com
Wed Aug 1 00:50:41 CEST 2001
Paul Prescod <paulp at ActiveState.com> wrote:
> Michael Chermside wrote:
> > ...
> > How about this:
> > def f():
> > for x in g():
> > yield x * 2
> > Of course it gives a generator, not a list... but that
> > seems to be a reasonable form to represent an infinite sequence.
> 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?
More information about the Python-list