explain why adding a new builtin won't work.
This commit is contained in:
parent
d163abe4d6
commit
cd1746477e
|
@ -98,6 +98,15 @@ Alternatives
|
||||||
advantage of evaluating strictly from left to right (not that that
|
advantage of evaluating strictly from left to right (not that that
|
||||||
is a requirement for being Pythonic -- list comprehensions don't).
|
is a requirement for being Pythonic -- list comprehensions don't).
|
||||||
|
|
||||||
|
Many people suggest adding a new builtin instead of extending the
|
||||||
|
syntax of the language, e.g.:
|
||||||
|
|
||||||
|
ifelse(condition, expression1, expression2)
|
||||||
|
|
||||||
|
This won't work the way a syntax extension will because both
|
||||||
|
expression1 and expression2 must be evaluated before the function
|
||||||
|
is called. There's no way to short-circuit the expression
|
||||||
|
evaluation.
|
||||||
|
|
||||||
Copyright
|
Copyright
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue