Title: Numeric operator predecence confusing
Type: enhancement Stage: needs patch
Components: Documentation Versions: Python 3.5, Python 3.4, Python 2.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: BreamoreBoy, docs@python, ezio.melotti, fossilet, jcea, ktt3ja, meador.inge
Priority: normal Keywords: easy, patch

Created on 2012-11-08 14:19 by fossilet, last changed 2014-07-06 15:43 by BreamoreBoy.

File name Uploaded Description Edit
16438.patch ktt3ja, 2012-11-22 21:33 review
Messages (10)
msg175163 - (view) Author: Yongzhi Pan (fossilet) * Date: 2012-11-08 14:19

"All numeric types (except complex) support the following operations, sorted by ascending priority."

It list '-' after '+', '/' after '*'. That is to mean '-' has higher precedence than '+'. That is wrong, and is contradicting with here:

This should be made clear.
msg175168 - (view) Author: Jesús Cea Avión (jcea) * (Python committer) Date: 2012-11-08 14:27
Precedence ordered per row. Same row, same precedence. I don't see any problem. It is natural math precedence. Closed as invalid.
msg175172 - (view) Author: Yongzhi Pan (fossilet) * Date: 2012-11-08 15:18
I mean the text at the first link need fix. '+' and '-' are not on the same row. And the doc says: "sorted by ascending priority", that means they have ascending priority.

The table in the reference is just right.
msg175178 - (view) Author: Jesús Cea Avión (jcea) * (Python committer) Date: 2012-11-08 15:29
You are right, Yongzhi Pan. Reopening. Not sure how to solve it. Delegating to docs@python.
msg176088 - (view) Author: Kiet Tran (ktt3ja) Date: 2012-11-22 02:08
I was trying to fix this, but I ran into a couple questions.

1) Once I put, say, "x + y" and "x - y" into the same table cell, what would a good format be? My preferred format is to have them on separate lines in the cell, but after a lot of googling on the syntax of reST (and trials and errors), I'm still unable to figure out how to do it. Using bullet points would mean I have to align elements in the "Notes" column with the ones in the "Operation" column somehow. Alternatively, I can separate them by comma, but the table would look a bit cluttered.

2) Should the functions abs, int, etc., belong in the same table that's meant to list operators by precedence?
msg176099 - (view) Author: Yongzhi Pan (fossilet) * Date: 2012-11-22 06:03
One possible solution:

We do not list priorities of the operations, instead link to the precedence table in the language reference.
msg176126 - (view) Author: Kiet Tran (ktt3ja) Date: 2012-11-22 21:33
Good idea.
msg176500 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-11-27 22:41
> I'm still unable to figure out how to do it

You could look at Doc/library/unittest.rst, there are some tables that span multiple lines.  If you want a newline in the output too I think you have to add a blank line in the cell.
msg176502 - (view) Author: Kiet Tran (ktt3ja) Date: 2012-11-28 01:05
That document actually doesn't have any table that spans multiple lines. Here's the html page:

Actually, I already know how to make a table span multiple lines from this stackoverflow page:

However, the problem is having the items in different columns match, as it depends on the width of the table, which is not fixed. For example, notice how the table is formatted nicely here:
But if I shrink the width, the formatting just goes wrong:

This is particularly problematic because some elements in the table have long lines.
msg222408 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-07-06 15:43
I find the numeric operator predecence simply wrong, not confusing, so +1 from me for applying the attached patch from ktt3ja.  It's as simple as possible but no simpler :)
Date User Action Args
2014-07-06 15:43:41BreamoreBoysetnosy: + BreamoreBoy

messages: + msg222408
versions: + Python 3.5, - Python 3.2, Python 3.3
2012-11-28 01:05:43ktt3jasetmessages: + msg176502
2012-11-27 22:41:58ezio.melottisetmessages: + msg176500
2012-11-22 21:33:24ktt3jasetfiles: + 16438.patch
keywords: + patch
messages: + msg176126
2012-11-22 06:03:08fossiletsetmessages: + msg176099
2012-11-22 02:08:18ktt3jasetnosy: + ktt3ja
messages: + msg176088
2012-11-08 22:01:20ezio.melottisetkeywords: + easy
nosy: + ezio.melotti

type: enhancement
stage: needs patch
2012-11-08 20:42:47meador.ingesetnosy: + meador.inge
2012-11-08 15:29:14jceasetstatus: closed -> open
resolution: not a bug ->
messages: + msg175178
2012-11-08 15:18:05fossiletsetmessages: + msg175172
2012-11-08 14:30:58mark.dickinsonsetstatus: open -> closed
2012-11-08 14:27:06jceasetresolution: not a bug

messages: + msg175168
nosy: + jcea
2012-11-08 14:19:31fossiletcreate