[Python-ideas] Assignments in list/generator expressions

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Apr 13 00:30:01 CEST 2011


Carl M. Johnson wrote:

> Isn't that ambiguous? What if someone used the conditional expression:
> ys = [y for x in xs letting y = f(x) if y else g(x)] ?

No more ambiguous than 'if' already is in a comprehension,
and that's resolved by requiring parens if one of the
clauses in the comprehension contains an 'if' expression.

-- 
Greg



More information about the Python-ideas mailing list