For review: PEP 308 - If-then-else expression
Paul Rubin
http
Sun Feb 9 23:44:45 EST 2003
"Samuele Pedroni" <pedronis at bluewin.ch> writes:
> I still prefer
>
> log.info(ok and "success!" or "failure.")
>
> over
>
> log.info(if ok: "success!" else: "failure")
OK, at that point it just get down to a matter of subjective
preference. I personally find the second version far more explicit
and understandable. I guess in C, x?y:z isn't usually convertable
to (x&&y)||z, but the comparable expression in Lisp would be
(or (and x y) z). One occasionally sees that, however
(if x y z) or (cond (x y) (t z)) is generally preferable.
More information about the Python-list
mailing list