Issue 20314: Potentially confusing formulation in 6.1.4. Template strings (original) (raw)

Created on 2014-01-20 17:10 by Gerrit.Holl, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 856 merged barry,2017-03-27 22:36
Messages (6)
msg208553 - (view) Author: Gerrit Holl (Gerrit.Holl) * Date: 2014-01-20 17:10
The standard library documentation “6.1. string — Common string operations” describes string formatting through the `.format` method and the corresponding mini-language, and the `Template` class. In the part describing the `Template` class (6.1.4) is the text: > Instead of the normal %-based substitutions, Templates support −basedsubstitutions,usingthefollowingrules:Thisispotentiallyconfusing.Thedocumentationinthissectionhasnotmadeanymentionof-based substitutions, using the following rules: This is potentially confusing. The documentation in this section has not made any mention of %-based substitutions. Rather, a novel reader may, at this point, think that {}-based substitution is normal. I would suggest to resolve this issue by simply not mentioning %-based substitutions, replacing the sentence above by: > Templates support basedsubstitutions,usingthefollowingrules:Thisispotentiallyconfusing.Thedocumentationinthissectionhasnotmadeanymentionof-based substitutions, using the following rules:
msg208554 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2014-01-20 17:18
+1.
msg208556 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2014-01-20 17:22
On Jan 20, 2014, at 05:10 PM, Gerrit Holl wrote: >This is potentially confusing. The documentation in this section has not >made any mention of %-based substitutions. Rather, a novel reader may, at >this point, think that {}-based substitution is normal. I would suggest to >resolve this issue by simply not mentioning %-based substitutions, replacing >the sentence above by: > >> Templates support $-based substitutions, using the following rules: +1 PEP 292 templates predate .format().
msg208557 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-01-20 17:34
I would suggest moving the section "4.7.2. printf-style String Formatting" from stdtypes to string, alongside the other two formatting specifications, or otherwise moving %-formatting and {}-formatting into the same page that is not stdtypes. 4.7.2 is a pretty long section, and it seems odd to me that it is still in that page instead of with the other string formatting specs, though it is the only place that would have made sense in a pre-{}-and-$-formatting world. On the other hand, Gerrit's proposed solution is a *lot* simpler :)
msg208558 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2014-01-20 17:43
> I would suggest moving the section "4.7.2. printf-style String > Formatting" from stdtypes to string That's something I wanted to do for a long time. Problem is that non-Intersphinx external links will break (and I guess quite a few people have a bookmark on that section)... so it might be good to keep 4.7.2 with a pointer.
msg290719 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2017-03-28 14:02
New changeset 9f74deba784fc8781d13ed564f69c02ed7c331bb by Barry Warsaw in branch 'master': Improve the documentation for template strings (#856) https://github.com/python/cpython/commit/9f74deba784fc8781d13ed564f69c02ed7c331bb
History
Date User Action Args
2022-04-11 14:57:57 admin set github: 64513
2017-03-28 14:04:40 barry set versions: + Python 3.7, - Python 2.7, Python 3.3, Python 3.4
2017-03-28 14:04:34 barry set status: open -> closedresolution: fixedstage: resolved
2017-03-28 14:02:09 barry set messages: +
2017-03-27 22:36:40 barry set pull_requests: + <pull%5Frequest759>
2017-03-27 22:22:16 barry set assignee: docs@python -> barry
2014-01-20 17:43:54 georg.brandl set messages: +
2014-01-20 17:35:57 zach.ware set versions: + Python 2.7, Python 3.4
2014-01-20 17:34:44 zach.ware set nosy: + zach.waremessages: +
2014-01-20 17:22:35 barry set nosy: + barrymessages: + title: Potentially confusing formulation in 6.1.4. Template strings -> Potentially confusing formulation in 6.1.4. Template strings
2014-01-20 17🔞18 georg.brandl set nosy: + georg.brandlmessages: +
2014-01-20 17:10:53 Gerrit.Holl create