[Python-ideas] Assignments in list/generator expressions

Carl M. Johnson cmjohnson.mailinglist at gmail.com
Tue Apr 12 05:53:24 CEST 2011


On Mon, Apr 11, 2011 at 2:14 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

>  ys = [y for x in xs letting y = f(x) if y]

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)] ? It seems like
the letting/given has to go last in order to eliminate the possible
ambiguity in the subsequent optional if clause.

-- Carl Johnson



More information about the Python-ideas mailing list