Operator precedence problem
steve at pearwood.info
Mon Jun 6 13:07:22 EDT 2016
On Mon, 6 Jun 2016 11:57 pm, Random832 wrote:
> Okay, can we settle on, as a principle, "the basic arithmetic operators
> (not to include **) are the only ones whose precedence can be presumed
> to be obvious to all readers,
> and other expressions may/should have
> parentheses to make it more clear, even when not strictly necessary to
> the meaning of the expression"?
Sure, why not? So long as it is a "should" and not a "must".
> Sure, it's obvious to _me_ that << and >> have higher precedence than &
> and |, and that "and" has a higher precedence than "or",
Blimey, you're right. I always thought `and` and `or` had the same
precedence. And now that I know better, I have no doubt that I will forget
More information about the Python-list