For review: PEP 308 - If-then-else expression
bokr at oz.net
Mon Feb 10 10:31:42 CET 2003
On Mon, 10 Feb 2003 04:25:22 +0100, "Samuele Pedroni" <pedronis at bluewin.ch> wrote:
>"Paul Rubin" <http://phr.cx@NOSPAM.invalid> ha scritto nel messaggio
>news:7xznp49639.fsf at ruckus.brouhaha.com...
>> "Samuele Pedroni" <pedronis at bluewin.ch> writes:
>> > > I'm not worrieed about you; I'm worried about someone else reading
>> > > your code who might not realize that (cond and expr1 or expr2)
>> > > doesn't always work, and might use it in a case where it fails.
>> > There are ~100 instances of that in the std lib code, see Tim Peters
>> > post or the std lib directly, is for all to see.
>> I see that as evidence that a conditional expression is really needed,
>> if the std lib is so full of kludgy workarounds for its absence.
>they are not kludgy if one is a bot <wink>
>I still prefer
>log.info(ok and "success!" or "failure.")
>print "auto colorizing turned", self.allow_colorizing and "on" or "off"
>log.info(if ok: "success!" else: "failure")
>print "auto colorizing turned", if self.allow_colorizing: "on" else: "off"
>print "auto colorizing turned", (if self.allow_colorizing: "on" else: "off")
>e.g. : seem spurious in an expression
log.info(ok ? "failure.", "success!" )
print "auto colorizing turned", (self.allow_colorizing ? "off", "on")
is pretty clear IMO, once you get used to the order, which I would put that
way so as to reserve
x ?? s0, s1, s2
to have an effect as if implemented by
x ? s0, s1
as if implemented by
More information about the Python-list