generator expressions and new ternary operator

Gerrit gerrit at
Mon Sep 13 09:02:43 CEST 2004

zipher wrote:
> It seems the debate over PEP 308 (if-then-else expression) occurred
> prior to the arrival of generator expressions.
> Mightn't this new latter syntax be the ticket to a "one obvious way"
> to write a ternary expression in python?
> >>> (foo(i) if i==42 else bar(i))   # i==42 ? foo(i) : bar(i)

No. This has been suggested, and been rejected. And since generator
expressions have nothing to do with ternary expressions, it is not a
reason to re-do the discussion. There are literally thousands of
messages in the archives, including sub-threads discussing exactly this
syntax. By the time you've (re-)read them all, we'll be way beyond
Python 3.0 ;-)


Weather in Twenthe, Netherlands 13/09 08:25:
	14.0°C Broken clouds mostly cloudy wind 4.5 m/s S (57 m above NAP)
Gerrit Holl - 2nd year student of Applied Physics, Twente University, NL.
Experiences with Asperger's Syndrome:

More information about the Python-list mailing list