For review: PEP 308 - If-then-else expression
Paul Rubin
phr-n2003b at NOSPAMnightsong.com
Sat Feb 8 17:15:43 EST 2003
Dave Brueck <dave at pythonapocrypha.com> writes:
> I like the PEP proposal _more_ than the C way because the implication of
> what is expected is stronger. I like the similarity between these two:
>
> z = x.Foo()
> z = x.Foo() if x else -1 # I expect z to get x.Foo() most of the time
The PEP proposal is uncomfortable in cases where you DON'T especially
expect one outcome more than the other:
maximum = x if (x > y) else y
seems more confusing than
maximum = (x > y) ? x : y
More information about the Python-list
mailing list