[Python-Dev] An issue recently brought up in patch #872326 (generator expression)

Guido van Rossum guido at python.org
Mon Mar 22 21:48:25 EST 2004


> Guido:
> > A free variable might be a function that itself references globals (or
> > at least nonlocals) that might change.
> > 
> > There is also the issue of exceptions:

Greg:
> Oviously there will be semantic differences, but the question is
> whether the consequences of them are serious enough to be worth
> treating the outermost iterator differently from the others.
> 
> I'm disturbed by the number of special rules we seem to be needing to
> make up in the name of getting generator expressions to DWIM. First we
> have free variables getting captured, which is unprecedented anywhere
> else; now we have some iterators being treated more equally than
> others.
> 
> I'm getting an "architecture smell" here. Something is wrong
> somewhere, and I don't think we're tinkering in the right place to fix
> it properly.

I'm not disagreeing -- I was originally vehemently against the idea of
capturing free variables, but Tim gave an overwhelming argument that
whenever it made a difference that was the desired semantics.

But I always assumed that the toplevel iterable would be different.

> I think I have an idea where the right place is, but I'll leave
> that to another post. I suspect the idea isn't going to go down
> well...

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list