parent
85fb287b33
commit
578b6df698
15
pep-0308.txt
15
pep-0308.txt
|
@ -36,7 +36,7 @@ Proposal
|
|||
|
||||
(if <condition>: <expression1> else: <expression2>)
|
||||
|
||||
Note that the enclosing parethesis are not optional.
|
||||
Note that the enclosing parentheses are not optional.
|
||||
|
||||
The resulting expression is evaluated like this:
|
||||
|
||||
|
@ -83,6 +83,19 @@ Alternatives
|
|||
|
||||
---
|
||||
|
||||
Holger Krekel proposed a new, minimally invasive variant:
|
||||
|
||||
<expression1> and <condition> else <expression2>
|
||||
|
||||
The concept behind it is that a nearly complete ternary operator
|
||||
already exists with and/or and this proposal is the least invasive
|
||||
change that makes it complete. Many respondants on the
|
||||
newsgroup found this to be the most pleasing alternative.
|
||||
However, a couple of respondants were able to post examples
|
||||
that were mentally difficult to parse.
|
||||
|
||||
---
|
||||
|
||||
Many C-derived languages use this syntax:
|
||||
|
||||
<condition> ? <expression1> : <expression2>
|
||||
|
|
Loading…
Reference in New Issue