For review: PEP 308 - If-then-else expression
Erik Max Francis
max at alcyone.com
Sat Feb 8 04:39:49 CET 2003
Peter Hansen wrote:
> Gerrit Holl wrote:
> > Guido van Rossum schreef op vrijdag 7 februari om 18:16:27 +0000:
> > > x if C else y if D else z <==> x if C else (y if D else z)
> > Doesn't this equal ((z ,y)[bool(D)], x)[bool(C)]? I think it's
> > good enough.
> If I saw *either* of those in real code produced by someone in my
> the code would immediately be rewritten. Neither is readable.
By the way, the same is true in C or C++ with the normal ternary
operator. Once you start chaining them together they get really ugly,
really fast. That's just pilot error (writing code which is hard to
read), not a flaw in the construct itself.
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ Shooters, looters / Now I got a laptop computer
\__/ Ice Cube
Kepler's laws / http://www.alcyone.com/max/physics/kepler/
A proof of Kepler's laws.
More information about the Python-list