4 ms·
> I really don't want to have to pull out an operator precedence chart in order to read your code Hard disagree here. I write code for people who can read the
by the5avage 2y ago
> I really don't want to have to pull out an operator precedence chart in order to read your code
Hard disagree here. I write code for people who can read the language. This includes operator precedence.
- shkkmo 2y agoThe more complex an expression grows, the less well it works to rely on operator precedence to indicate structure to the reader. Additionally, I think assuming the reader is aware of every. nuance of the language is an extremely bad idea unless you are and will always be the only developer. If you are doing anything weird or tricky or rare, I'd highly recommend linking the documentation or providing an explanation.
- nmeofthestate 2y ago>I write code for people who can read the language Programming languages often have syntax that's acknowledged as a source of confusion and bugs and better avoided. The line is not hard and fast, but I write C++ and there's "C++", and then there's "the C++ subset that you should use" (I probably couldn't write C++ code without tools slapping me for using the wrong parts). Operator precedence is debatable but our tools force the use of parentheses to disambiguate.
- stavros 2y agoThis is true, and, in this case, "confusion avoided" and "what Python does" coincide. The "double equals doing the right thing" is only confusing if you're both unfamiliar with Python and familiar with language design, which is a very small set of people. People unfamiliar with programming will assume that "if a == b == c" is only true if all three things are the same, and people familiar with Python will know that that is, indeed, what it means.