Generator Comprehensions? was Re: a break for comprehensions

Roman Suzi rnd at onego.ru
Tue Jul 31 16:35:45 EDT 2001


On Tue, 31 Jul 2001, Paul Prescod 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()]

O, yes! Generators need lambda form too!

Sincerely yours, Roman Suzi
-- 
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Tuesday, July 31, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "All things are green unless they are not." _/





More information about the Python-list mailing list