Odd closure issue for generators

Brian Quinlan brian at sweetapp.com
Thu Jun 4 23:25:47 EDT 2009

Scott David Daniels wrote:
> When you evaluate a lambda expression, the default args are evaluated,
> but the expression inside the lambda body is not.  When you apply that
> evaluated lambda expression, the expression inside the lambda body is
> is evaluated and returned.

But that's not really the issue. I knew that the lambda was not 
evaluated but thought each generator expression got its own context 
rather than sharing one.

Taken in isolation, having one context per expression has more 
compelling semantics but it is inconsistent with the obvious 
transliteration of the generator into a loop.


More information about the Python-list mailing list