3 ms·
I think it could be ambiguous in certain situations. Let's say I wanted to conditionally set a variable to one of two negative constants. In the current syntax,
by scoppini 10y ago
I think it could be ambiguous in certain situations. Let's say I wanted to conditionally set a variable to one of two negative constants. In the current syntax, that would look like:
x = -1 if y else -2
However, with your syntax, it would look like:
x = if y -1 else -2
Which could be possibly confused with trying to subtract 1 from y.
- oxryly1 10y agoAh, and Python uses whitespace and colons to disambiguate, which would ruin the efficiency of this form.