conditional expressions

Terry Reedy tjreedy at
Thu Sep 26 23:47:00 CEST 2002

"Alex Martelli" <aleax at> wrote in message
news:7nHk9.172208$pX1.6117207 at
> The reason
>         zz = a and b or c
> is not the same thing as
>         zz = a ? b : c
> is that, when a is true and b is false, the former returns c,
> while the latter returns b.

In almost all the practical cases where I have thought about using
this,  b is *not* false or cannot become false, in which important and
real case the two expressions *are* equivalent.

I think this is an elegant hack, and so I shared it in response to the
OP.  Others think it ugly.  So be it.

Terry J. Reedy

More information about the Python-list mailing list