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

Bengt Richter bokr at
Mon Feb 10 10:31:42 CET 2003

On Mon, 10 Feb 2003 04:25:22 +0100, "Samuele Pedroni" <pedronis at> wrote:

>"Paul Rubin" <> ha scritto nel messaggio
>news:7xznp49639.fsf at
>> "Samuele Pedroni" <pedronis at> 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
> and "success!" or "failure.")
>print "auto colorizing turned", self.allow_colorizing and "on" or "off"
> 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
OTOH, ? "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
correpsonding to
    x ? s0, s1
as if implemented by

Bengt Richter

More information about the Python-list mailing list