PEP 308: Alternative conditional operator forms
Andrew Koenig
ark at research.att.com
Tue Feb 11 11:02:42 EST 2003
Robin> And if parentheses aren't required, then that might be the one
Robin> case where I would consider leaving them out. Nevertheless, I
Robin> still think required parentheses are a good idea. I don't see
Robin> much significant difference between:
Robin> f((x if C else y))
Robin> and:
Robin> f([x for x in L])
I do. Enclosing list comprehensions in brackets makes it clear that
they're generating lists. In fact, I had to check to see that it
wasn't possible to write (x for x in L) as a tuple comprehension,
which is what I would have expected it to mean if it meant anything.
On the other hand, I don't see much difference between
f(x if C else y)
and
f(lambda x: x+1)
in which extra parentheses are already not required.
--
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark
More information about the Python-list
mailing list