[Python-Dev] [872326] generator expression implementation
Michael Hudson
mwh at python.net
Mon Jan 12 10:55:50 EST 2004
Jeremy Hylton <jeremy at alum.mit.edu> writes:
> On Mon, 2004-01-12 at 05:58, Armin Rigo wrote:
>> Sorry to bring this out again, I didn't find a reference about the following
>> issue in generator expressions:
>>
>> (for x in expr)
>>
>> When should 'expr' be evaluated? A priori, one would expect it to be
>> evaluated immediately, but it is not what the suggested implementation does:
>>
>> def __gen():
>> for x in expr:
>> yield x
>> __gen()
>
> First a quick clarification: Is the "suggested implementation" SF patch
> 872326 or is it that implementation sketch in PEP 289? The latter
> certainly suggests it, but it's hard to tell even then if it's
> intentional. Perhaps we should work out the formal specification part
> of the PEP in parallel with the implementation. The PEP currently says
> that the reference manual should contain a specification, but that spec
> is supposed to be part of the PEP, too.
>
> I agree, at any rate, that the expression should be evaluated
> immediately. That's easy enough to implement:
>
> def __gen(it):
> for x in it:
> yield x
> __gen()
Should be __gen(expr), right?
Cheers,
mwh
--
For their next act, they'll no doubt be buying a firewall
running under NT, which makes about as much sense as
building a prison out of meringue. -- -:Tanuki:-
-- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html
More information about the Python-Dev
mailing list