[Python-Dev] PEP 289: Generator Expressions

Raymond Hettinger python at rcn.com
Thu Oct 23 11:55:08 EDT 2003


[Guido]
> No, I meant that "for x.a in mylist: ..." is valid but shouldn't be,
> and consequently (because they all share the same syntax) this is also
> allowed in list comprehensions and generator expressions.  All uses
> should be disallowed.
> 
> > If so, I can't imagine why.  Or does in mean that
> > the induction variable can be in that form, "(x for x.a in mylist)".
> > Surely, this would never be allowed.
> 
> We can prevent it for generator expressions, but it's too late for
> list comprehensions and regular for loops -- we'll have to go
> deprecate it there.


Since the issue is not unique to generator expressions, I recommend
leaving it out of the PEP and separately dealing with all for-constructs
at one time.

It's harder to win support for proposals that use the word "deprecate".


Raymond Hettinger




More information about the Python-Dev mailing list