For review: PEP 308 - If-then-else expression

Dan Schmidt dfan at
Sat Feb 8 06:30:39 CET 2003

"James P. Rutledge" <jrut at> writes:

| It *might* be possible to obtain the effects of the proposed expression
| in a more general way by extending the semantics of the following
| existing construct:
|    ("html", "text")[is_html(msg)]
| The above expression provides the string "html" or "text" depending upon
| the return value of the function "is_html".

But it does the opposite of what you want (I assume).

Sorry to keep pointing this out in people's examples, but I think it's
actually a good argument why the current ternary-operator workarounds
are not sufficient.



More information about the Python-list mailing list