Issue 31487: Improve f-strings documentation wrt format specifiers
Created on 2017-09-15 17:34 by Mariatta, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 3604 | merged | Mariatta, 2017-09-15 17:35 | |
| PR 3619 | merged | python-dev, 2017-09-16 19:00 | |
| PR 3627 | merged | Mariatta, 2017-09-17 14:38 | |
| PR 3628 | merged | python-dev, 2017-09-17 14:43 | |
| Messages (5) | |||
|---|---|---|---|
| msg302279 - (view) | Author: Mariatta (Mariatta) * ![]() |
Date: 2017-09-15 17:34 | |
Provide a couple more examples of using format specifiers in f-string. |
|||
| msg302350 - (view) | Author: Mariatta (Mariatta) * ![]() |
Date: 2017-09-16 19:01 | |
New changeset 46c1052404c1a6e4d35af8e96613db8a4be75b52 by Mariatta (Miss Islington (bot)) in branch '3.6': bpo-31487: Improve f-strings documentation (GH-3604) (GH-3619) https://github.com/python/cpython/commit/46c1052404c1a6e4d35af8e96613db8a4be75b52 |
|||
| msg302367 - (view) | Author: Mariatta (Mariatta) * ![]() |
Date: 2017-09-17 14:43 | |
New changeset 63c591c0b0b57870a606e8edc59afe6264e7504d by Mariatta in branch 'master': bpo-31487: Update F-strings doc example (GH-3627) https://github.com/python/cpython/commit/63c591c0b0b57870a606e8edc59afe6264e7504d |
|||
| msg302368 - (view) | Author: Mariatta (Mariatta) * ![]() |
Date: 2017-09-17 14:57 | |
New changeset 4f6bae9677c0e5398e64c503fd3c19cae94567da by Mariatta (Miss Islington (bot)) in branch '3.6': bpo-31487: Update F-strings doc example (GH-3627) (GH-3628) https://github.com/python/cpython/commit/4f6bae9677c0e5398e64c503fd3c19cae94567da |
|||
| msg302397 - (view) | Author: Martin Panter (martin.panter) * ![]() |
Date: 2017-09-18 00:14 | |
>>> f"{number:#0x}" # using integer format specifier
It’s not clear what your purpose was adding the above line, but the zero flag (0) does nothing because there is no “width” field. I think it could be misleading, because it is actually the “#x” codes that generate the “0x” prefix.
If you want to illustrate a minimum width, I suggest something like
>>> f"{number:#06x}"
'0x0400'
or (if the number is never negative)
>>> f"0x{number:04X}"
'0x0400'
Or if you don’t care about the width:
>>> f"{number:#x}"
'0x400'
|
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:52 | admin | set | github: 75668 |
| 2017-09-18 00:14:24 | martin.panter | set | nosy:
+ martin.panter messages: + msg302397 |
| 2017-09-17 14:57:10 | Mariatta | set | messages: + msg302368 |
| 2017-09-17 14:43:47 | python-dev | set | pull_requests: + pull_request3617 |
| 2017-09-17 14:43:33 | Mariatta | set | messages: + msg302367 |
| 2017-09-17 14:38:38 | Mariatta | set | pull_requests: + pull_request3616 |
| 2017-09-16 19:01:58 | Mariatta | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2017-09-16 19:01:33 | Mariatta | set | messages: + msg302350 |
| 2017-09-16 19:00:05 | python-dev | set | pull_requests: + pull_request3610 |
| 2017-09-15 17:49:38 | Mariatta | set | versions: + Python 3.6, Python 3.7 |
| 2017-09-15 17:35:08 | Mariatta | set | keywords:
+ patch stage: patch review pull_requests: + pull_request3595 |
| 2017-09-15 17:34:45 | Mariatta | create | |
