Operator precedence problem

Random832 random832 at fastmail.com
Mon Jun 6 14:44:12 EDT 2016


On Mon, Jun 6, 2016, at 13:07, Steven D'Aprano wrote:
> 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
> it again.

A good way to remember it is that "and" is analogous to multiplication,
and "or" is analogous to addition. Which is, I assume, _why_ they have
the same precedence. (why ^ is between | and &, though, is a mystery to
me.)


More information about the Python-list mailing list