I just thought of something: now the syntax looks like if C:E1 else:E2,
we can also allow one or more elif parts.
This commit is contained in:
parent
1d3b81205e
commit
85fb287b33
|
@ -48,6 +48,13 @@ Proposal
|
||||||
- If <condition> is false, <expression2> is evaluated and is the
|
- If <condition> is false, <expression2> is evaluated and is the
|
||||||
result of the whole thing.
|
result of the whole thing.
|
||||||
|
|
||||||
|
A natural extension of this syntax is to allow one or more 'elif'
|
||||||
|
parts:
|
||||||
|
|
||||||
|
(if <cond1>: <expr1> elif <cond2>: <expr2> ... else: <exprN>)
|
||||||
|
|
||||||
|
This will be implemented if the proposal is accepted.
|
||||||
|
|
||||||
Note that at most one of <expression1> and <expression2> is
|
Note that at most one of <expression1> and <expression2> is
|
||||||
evaluated. This is called a "short-circuit expression"; it is
|
evaluated. This is called a "short-circuit expression"; it is
|
||||||
similar to the way the second operand of 'and' / 'or' is only
|
similar to the way the second operand of 'and' / 'or' is only
|
||||||
|
|
Loading…
Reference in New Issue