On 8/17/2016 2:39 PM, Random832 wrote:
On Wed, Aug 17, 2016, at 14:27, Terry Reedy wrote:
That particular syntax was not really considered. At least 10 versions
using 'if', 'then', 'else', and other tokens were.
They all had the problem of requiring a new keyword such as 'then' or
some other innovation.
Why not just if(cond, trueval, falseval), a la Visual Basic?
It's too late to change now, but I'm curious as to whether it was
considered or not.
It is already valid Python, parsed as 'if' 'tuple'
>>> if(1,2): 3
3
A space after 'if' is not optional if the next char is an identifier
char, as in 'ifx' as this is parsed as the identifier 'ifx', not 'if' 'x'.
Anyone can define an iff(cond, true_func, false_func) function
def iff(cond, f_true, f_false):
return (f_true if cond else f_false)()
or a non-short-circuiting iff(cond, true_val, false_val) function, but
it hardly seems worth the effort.
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list