classification
Title: Docs example: converting mixed types to floating point
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Mariatta Nosy List: Mariatta, MihaiHimself, docs@python, terry.reedy
Priority: low Keywords: easy

Created on 2017-05-14 09:08 by MihaiHimself, last changed 2017-05-29 22:25 by Mariatta. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1701 merged gfyoung, 2017-05-21 20:57
PR 1856 merged Mariatta, 2017-05-29 21:48
PR 1857 merged Mariatta, 2017-05-29 21:48
Messages (9)
msg293641 - (view) Author: Mihai Borobocea (MihaiHimself) Date: 2017-05-14 09:08
Section 3.1.1 in the Docs states:
"operators with mixed type operands convert the integer operand to floating point"
https://docs.python.org/3/tutorial/introduction.html

But gives an example using the division operator:
>>> 3 * 3.75 / 1.5
7.5
>>> 7.0 / 2
3.5

In Python 3, division always returns a float, e.g. when all operands are integers:
>>> 3 * 3 / 1
9.0
>>> 7 / 2
3.5

To illustrate that "operators with mixed type operands convert the integer operand to floating point" the example should not use division. For example:
>>> 3 * 3.75 - 1
10.25
>>> 7.0 + 2
9.0
msg293967 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-05-19 19:18
Agreed.  Also, I think one example is enough.  A good sprint fix.
msg294715 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-05-29 21:26
New changeset e405d4b8dfb8b497e1c3d1f0f8e28030040c165e by terryjreedy (gfyoung) in branch 'master':
bpo-30361: Use better example for mixed-type operands (#1701)
https://github.com/python/cpython/commit/e405d4b8dfb8b497e1c3d1f0f8e28030040c165e
msg294716 - (view) Author: Mariatta Wijaya (Mariatta) * (Python committer) Date: 2017-05-29 21:37
Thanks for merging the PR, Terry.

Now it needs backport :)
msg294717 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-05-29 21:41
Go ahead.  I don't care much either way.
msg294718 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-05-29 22:19
New changeset d52f47a8f7794ee09151973a00d29c8612672e7a by terryjreedy (Mariatta) in branch '3.6':
[3.6] bpo-30361: Use better example for mixed-type operands (GH-1701) (#1856)
https://github.com/python/cpython/commit/d52f47a8f7794ee09151973a00d29c8612672e7a
msg294719 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-05-29 22:20
New changeset 03c7cfcd52be702957cc174f5cb2ce4c8be8bfca by terryjreedy (Mariatta) in branch '3.5':
[3.5] bpo-30361: Use better example for mixed-type operands (GH-1701) (#1857)
https://github.com/python/cpython/commit/03c7cfcd52be702957cc174f5cb2ce4c8be8bfca
msg294720 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-05-29 22:23
Just curious, what sprint?
msg294721 - (view) Author: Mariatta Wijaya (Mariatta) * (Python committer) Date: 2017-05-29 22:25
Sorry, I don't know whether this was a sprint project or not.]
Saw that the original PR has sprint label on it, I merely copied them over to the backport PRs.

Thanks.
History
Date User Action Args
2017-05-29 22:25:44Mariattasetmessages: + msg294721
2017-05-29 22:23:28terry.reedysetstatus: open -> closed
type: enhancement
messages: + msg294720

resolution: fixed
stage: backport needed -> resolved
2017-05-29 22:20:49terry.reedysetmessages: + msg294719
2017-05-29 22:19:33terry.reedysetmessages: + msg294718
2017-05-29 21:48:14Mariattasetpull_requests: + pull_request1940
2017-05-29 21:48:01Mariattasetpull_requests: + pull_request1939
2017-05-29 21:41:57terry.reedysetmessages: + msg294717
2017-05-29 21:37:43Mariattasetmessages: + msg294716
stage: backport needed
2017-05-29 21:26:34terry.reedysetmessages: + msg294715
2017-05-21 20:57:02gfyoungsetpull_requests: + pull_request1797
2017-05-19 19:18:32terry.reedysetkeywords: + easy
nosy: + terry.reedy
messages: + msg293967

2017-05-14 13:45:04Mariattasetpriority: normal -> low
assignee: docs@python -> Mariatta

nosy: + Mariatta
2017-05-14 09:08:39MihaiHimselfcreate