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

Erik Max Francis max at alcyone.com
Mon Feb 10 23:05:09 EST 2003


Paul Moore wrote:

> Erik Max Francis <max at alcyone.com> writes:
> 
> > I think this is a lot more than just preference.  To those not
> > familiar
> > with the idiom, `C and x or y' is downright obtuse.  He may prefer
> > it
> > because it is a few characters shorter (and only a _few_ at that),
> > but
> > it is only clear if you already know the idiom.  Furthermore, as has
> > been said over and over again, it's _broken_ (if x is false).
> 
> In this instance, x is *not* false. It is "success!", which evaluates
> as true. As has been pointed out (in various contexts) over and over
> again.

Obviously, but if you come to rely on the idiom, it's easy to forget
that it doesn't work properly if x is false.  As we've seen from Andrew
Koenig's example of an _improper_ use of this construct in the standard
library.

The construct works in this specific case, yes.  It does not work in the
general case, however.  That is fact.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Ride / Ride this wave of mine
\__/ Res
    Esperanto reference / http://www.alcyone.com/max/lang/esperanto/
 An Esperanto reference for English speakers.




More information about the Python-list mailing list