Title: Mistake in FAQ about converting number to string.
Type: Stage: resolved
Components: Documentation Versions: Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Mariatta, cheryl.sabella, docs@python, grottrumsel, matrixise, miss-islington, pablogsal, xtreak
Priority: normal Keywords: easy, patch

Created on 2018-10-31 17:07 by grottrumsel, last changed 2019-02-19 14:47 by cheryl.sabella. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11911 merged matrixise, 2019-02-18 09:17
Messages (6)
msg329000 - (view) Author: Pawel (grottrumsel) Date: 2018-10-31 17:07
In this question:

There is a statement:
"{:.3f}".format(1/3) yields '0.333'


In [2]: "{:.3f}".format(1/3)
Out[2]: '0.000'

In [3]: "{:.3f}".format(1/3.0)
Out[3]: '0.333'
msg329015 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2018-10-31 20:25
Yep, this is incorrect in Python 2 unless `from __future__ import division` is imported at the beginning. Would you want to make a PR against the 2.7 branch to correct this?
msg335798 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python triager) Date: 2019-02-18 07:41
This is a good first issue. Python 3 docs uses `{:.3f}".format(1.0/3.0)` that was changed as part of 04d8a245f162b33e6c861ba0869918d9262be63e. Python 2 docs could be changed too to use floats that makes the example correct.
msg335800 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2019-02-18 08:29
I am working on this issue.
msg335802 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2019-02-18 09:18
Hi @xtreak,

I have just submitted a PR but where I explain the change with Python2/3 and the division operator.

Have a nice day,
msg335910 - (view) Author: miss-islington (miss-islington) Date: 2019-02-19 09:26
New changeset c611db4942a07c81f54e6584615bbddc51034a77 by Miss Islington (bot) (Stéphane Wirtel) in branch '2.7':
[2.7] bpo-35126: Fix a mistake in FAQ about converting number to string (GH-11911)
Date User Action Args
2019-02-19 14:47:59cheryl.sabellasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-02-19 09:26:06miss-islingtonsetnosy: + miss-islington
messages: + msg335910
2019-02-19 08:12:20matrixisesetkeywords: + easy
2019-02-18 09:18:45matrixisesetmessages: + msg335802
2019-02-18 09:17:17matrixisesetkeywords: + patch
stage: patch review
pull_requests: + pull_request11937
2019-02-18 08:29:05matrixisesetnosy: + matrixise
messages: + msg335800
2019-02-18 07:41:37xtreaksetnosy: + Mariatta, cheryl.sabella
messages: + msg335798
2018-11-01 07:16:51xtreaksetnosy: + xtreak
2018-10-31 20:25:46pablogsalsetnosy: + pablogsal
messages: + msg329015
2018-10-31 17:07:39grottrumselcreate