A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-January/041951.html below:

[Python-Dev] [872326] generator expression implementation

[Python-Dev] [872326] generator expression implementationJeremy Hylton jeremy at alum.mit.edu
Mon Jan 12 10:41:48 EST 2004
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()

Jeremy



More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4