For review: PEP 308 - If-then-else expression
Samuele Pedroni
pedronis at bluewin.ch
Sun Feb 9 22:25:22 EST 2003
"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"
over
log.info(if ok: "success!" else: "failure")
print "auto colorizing turned", if self.allow_colorizing: "on" else: "off"
-or-
print "auto colorizing turned", (if self.allow_colorizing: "on" else: "off")
e.g. : seem spurious in an expression
More information about the Python-list
mailing list