This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gvanrossum
Date 2004-03-22.23:00:59
SpamBayes Score
Marked as misclassified
Logged In: YES 

Sorry, I meant the first, not the last. I was confused about 
how the 'for' clauses are nested, but the outermost one is 
the first.

So the nesting remark is probably just confusing and wrong; 
ignore it.

What I meant is:

(f(x,y) for x in A() for y in B(x))

should IMO precompute A(), but not B(x). I guess the 
equivalent generator function would be:

def __gen(__outer__=A(), f=f, B=B):
  for x in __outer__:
    for y in B(x):
      yield f(x,y)

In general the value of every free variable used anywhere 
except in the outer expression should be captured; the 
*value* of the outer expression should be captured. This 
should give the least surprising semantics in a variaty of use 
Date User Action Args
2007-08-23 15:31:38adminlinkissue872326 messages
2007-08-23 15:31:38admincreate