This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Operator precedence table in 5.15 should be highest to lowest precedence
Type: Stage: patch review
Components: Documentation Versions: Python 3.10, Python 3.9, Python 3.8, Python 3.7, Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Joseph Schachner, amaajemyfren, docs@python, skip.montanaro, skrah, terry.reedy
Priority: normal Keywords: patch

Created on 2015-08-24 13:08 by Joseph Schachner, last changed 2022-04-11 14:58 by admin.

Pull Requests
URL Status Linked Edit
PR 20572 closed amaajemyfren, 2020-06-01 15:36
Messages (4)
msg249046 - (view) Author: Joseph Schachner (Joseph Schachner) Date: 2015-08-24 13:08
We should not make people who need to read Python documentation do an extra transformation in their heads to correctly understand that in section 5.15 higher precedence is at the bottom of the table and lower precedence is at the top. Because the documentation has this table inverted from the way it is usually presented in other references, one of the top hits in a Google search shows an instructor felt the need to make a version in the usual "high to low precedence" order to show students, see:
That version is so much more comfortable for me to read, it seems almost strange, but it is true. Please consider changing section 5.15 so it would not need the top paragraph explaining that the table order is not what the reader probably expects, instead just present the table as at the link above - in the order the reader does expect - higher precedence on top, lower on the bottom. That only needs two short sentences of explanation that don't make the reader think "wait ... what?"
msg249051 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2015-08-24 14:43
Yacc uses low to high.
msg249056 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2015-08-24 15:12
YACC might be an outlier as well. In any case, it's probably better to use other common programming languages as a gauge of what's typical. A quick check of C, C#, C++, Java, Perl, Ruby, and Haskell shows they all list operator precedence in order from highest to lowest.
msg249057 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2015-08-24 15:23
Agreed.  I'm not sure though what the reason for this convention is:
The flow in Grammar/Grammar (low to high) feels quite natural to me.

That said, I'm +-0 on the change.
Date User Action Args
2022-04-11 14:58:20adminsetgithub: 69109
2020-06-01 15:36:04amaajemyfrensetkeywords: + patch
nosy: + amaajemyfren

pull_requests: + pull_request19812
stage: patch review
2020-05-31 13:15:22serhiy.storchakasetversions: + Python 3.6, Python 3.7, Python 3.8, Python 3.9, Python 3.10, - Python 2.7
2015-08-29 05:10:37terry.reedysetnosy: + terry.reedy
2015-08-24 15:23:09skrahsetmessages: + msg249057
2015-08-24 15:12:05skip.montanarosetnosy: + skip.montanaro
messages: + msg249056
2015-08-24 14:43:00skrahsetnosy: + skrah
messages: + msg249051
2015-08-24 13:08:32Joseph Schachnercreate