Issue 35126: Mistake in FAQ about converting number to string.
Created on 2018-10-31 17:07 by grottrumsel, last changed 2022-04-11 14:59 by admin. 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: https://docs.python.org/2.7/faq/programming.html#how-do-i-convert-a-number-to-a-string There is a statement: "{:.3f}".format(1/3) yields '0.333' While 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) * ![]() |
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) * ![]() |
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) * ![]() |
Date: 2019-02-18 08:29 | |
I am working on this issue. |
|||
| msg335802 - (view) | Author: Stéphane Wirtel (matrixise) * ![]() |
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) https://github.com/python/cpython/commit/c611db4942a07c81f54e6584615bbddc51034a77 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:07 | admin | set | github: 79307 |
| 2019-02-19 14:47:59 | cheryl.sabella | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2019-02-19 09:26:06 | miss-islington | set | nosy:
+ miss-islington messages: + msg335910 |
| 2019-02-19 08:12:20 | matrixise | set | keywords: + easy |
| 2019-02-18 09:18:45 | matrixise | set | messages: + msg335802 |
| 2019-02-18 09:17:17 | matrixise | set | keywords:
+ patch stage: patch review pull_requests: + pull_request11937 |
| 2019-02-18 08:29:05 | matrixise | set | nosy:
+ matrixise messages: + msg335800 |
| 2019-02-18 07:41:37 | xtreak | set | nosy:
+ Mariatta, cheryl.sabella messages: + msg335798 |
| 2018-11-01 07:16:51 | xtreak | set | nosy:
+ xtreak |
| 2018-10-31 20:25:46 | pablogsal | set | nosy:
+ pablogsal messages: + msg329015 |
| 2018-10-31 17:07:39 | grottrumsel | create | |
