generator expressions and new ternary operator

zipher zondervanz at
Mon Sep 13 08:02:30 CEST 2004

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)


More information about the Python-list mailing list