News for hackers. Stuff that matters.
Re:PEP 308 and why I still hate Python by oxryly1 on Thursday March 09, 2017 @08:39PM (#13835622)
Why didn't Python do this:

  x = if condition a else b

?
Re:PEP 308 and why I still hate Python by scoppini on Thursday March 09, 2017 @09:00PM (#13835717)
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.
Re:PEP 308 and why I still hate Python by oxryly1 on Thursday March 09, 2017 @09:05PM (#13835737)
Ah, and Python uses whitespace and colons to disambiguate, which would ruin the efficiency of this form.
Re:PEP 308 and why I still hate Python by debacle on Thursday March 09, 2017 @08:56PM (#13835696)
Because what they actually want is something like:

    checkSomeValue() && doOtherThing()
Re:PEP 308 and why I still hate Python by secstate on Thursday March 09, 2017 @08:59PM (#13835708)
Because that scans as:

Variable x should be assigned if condition a true, otherwise b.

Re:PEP 308 and why I still hate Python by oxryly1 on Thursday March 09, 2017 @09:01PM (#13835725)
But "condition" is just a placeholder. A concrete example would be:

   msg = if (status == 0) "done" else "error"
Re:PEP 308 and why I still hate Python by secstate on Thursday March 09, 2017 @09:04PM (#13835734)
Take away the parens (which python is pretty explicit such structure should not be required to be legible).

msg = if status == 0 "done" else "error"

From a compiler perspective that's a bear to parse.

Re:PEP 308 and why I still hate Python by liveoneggs on Thursday March 09, 2017 @09:21PM (#13835809)
too much like perl?