[issue38060] precedence (relational, logical operator)not working with single value

Steven D'Aprano report at bugs.python.org
Tue Sep 10 19:54:36 EDT 2019


Steven D'Aprano <steve+python at pearwood.info> added the comment:

I think that the problem is that the precedence table may be technically 
correct, but it doesn't describe the actual behaviour of expressions 
including the boolean operators ``or`` and ``and`` for exactly the 
reason Tim gives:

> Precedence rules alone are too feeble to capture that.

If I didn't know that boolean operators short-circuited, I too would 
have expected that an expression like ``9 or 7 < "str"`` would have 
raised an exception.

The documentation (precedence table) isn't wrong, it's just incomplete. 
The information needed exists, but it is elsewhere, and if you don't 
already know it, you don't know that you need to look for it.

I think that the precedence table could do with a footnote on the two 
boolean operators describing their interaction with short-circuiting 
behaviour and linking back to the relevant section 6.11.

https://docs.python.org/3/reference/expressions.html#boolean-operations

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38060>
_______________________________________


More information about the Python-bugs-list mailing list