Generator Comprehensions? was Re: a break for comprehensions
Michael Chermside
mcherm at destiny.com
Tue Jul 31 14:58:52 EDT 2001
> > I believe a separate syntax would be required to represent such a
> radically
> > different object. But you, of course, may know better ... if you're
> looking
> > for a syntax, one possibility would be:
> >
> > [[x * 2 for x in g()]]
> >
> > regards
> > Steve
>
> That particular syntax won't do since
[..snip..]
>
> How about [... x * 2 for x in g()]
>
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.
-- Michael Chermside
More information about the Python-list
mailing list