For review: PEP 308 - If-then-else expression
Erik Max Francis
max at alcyone.com
Mon Feb 10 08:45:05 CET 2003
Roman Suzi wrote:
> On Sun, 9 Feb 2003, Erik Max Francis wrote:
> > if C1: x elif C2: y else: z
> It is not very clear in nested variant as the code is not readable
> any more... Guido can drop indents in Python as well.
Well, sure, I wouldn't go nuts over the chained syntax either, but it's
the logical extension and _if you accent the basic syntax_ it's the
right way to make it multiway instead of simply two-way.
if C: x elif D: y else: z
certainly looks better than
if C: x else: if D: y else: z
The `else: if' is screaming, "Change me to an `elif'."
Granted if you don't like the `if C: x else: y' approach in the first
place then this is going to be even less appealing.
> Also, if this is to happen, next logical step will be this:
> try: x except: y
That's a logical fallacy known as the "slippery slope argument." I'm
not seeing the slippery slope here; I don't see people clamoring for
try...except statements to be bound up in exceptions.
Besides, does it offend you that
can be written as
if condition: doSomething
? It seems _that_ was the first step down the "slippery slope," if
indeed there was one (which I don't think there is).
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ No man quite believes in any other man.
\__/ H.L. Mencken
Alcyone Systems / http://www.alcyone.com/
Alcyone Systems, San Jose, California.
More information about the Python-list