|
|
|
|
|
by goku12
358 days ago
|
|
I also found the conditional syntax (with the condition in the middle) a bit awkward compared to Rust's or even C's. But there is certainly a common operation. And this is the syntax chosen by the Python language designers. I'm curious. Why do you think it is bad? What are the possible issues that this style can cause? |
|
On a more basic level, I just don't see any good reason to put the condition in the middle.
Lisp: `(if <cond> <then> <else>)` Haskell: `if <cond> then <then> else <else>` Rust: `if <cond> { <then> } else { <else> }`
All the above read fine and normal. In the python version the order of execution is different then the left-to-right reading order.
It's not like it's a fatal flaw for a language to do it like Python. But it is just silly IMO. My POV is that I actually really like if-expressions, but hate the condition-in-the-middle syntax, so I tend to avoid it unless it's really short. When code changes slightly and becomes longer I'd rather not have to always double take if this now should change to an if-statment or to an expression etc.