[proxy] github.com← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light
/ cpython Public

Conversation

Copy link
Member

warsaw commented Mar 27, 2017

bpo-20314
warsaw added the docs Documentation in the Doc dir label Mar 27, 2017
warsaw self-assigned this Mar 27, 2017
Copy link

@warsaw, thanks for your PR! By analyzing the history of the files in this pull request, we identified @birkenfeld, @ncoghlan and @benjaminp to be potential reviewers.

Template strings provide simpler string substitutions as described in
:pep:`292`. The primary use case for template strings is for
internationalization (i18n) since in those contexts, the more featured yet
complex formatting languages for f-strings and ``str.format()`` can make
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The informal term "f-string" is not used in the documentation. It would be better to write "formatted string literals".

:pep:`292`. The primary use case for template strings is for
internationalization (i18n) since in those contexts, the more featured yet
complex formatting languages for f-strings and ``str.format()`` can make
translations more difficult to implement. As an example of a library for i18n
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And f-strings can't be used for internationalization at all. This is a syntax, not format string. printf-like formatting can be mentioned. It is used for internationalization and is more powerful and more complex than Template.

Copy link
Member Author

warsaw Mar 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f-strings were originally touted for translations, but I did point out the inappropriateness of them for that purpose. Maybe we don't mention any of them explicitly, and just say "other built-in string formatting features".

Advanced usage: you can derive subclasses of :class:`Template` to customize
the placeholder syntax, delimiter character, or the entire regular expression
used to parse template strings. To do this, you can override these class
attributes:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth to mention that that attributes should be set before finalizing the class creation (see bpo-12518)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good catch. I'll handle that in this PR too.

Also, add bpo-12518 to the list of issues fixed by this PR.
Copy link
Member

serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I should add that I used Template for user customization of the output. For example, the user can specify the format string to output a limited set of variables in the status bar. This may include translation, but not necessarily.

Copy link
Member Author

warsaw commented Mar 28, 2017 via email

warsaw merged commit 9f74deb into python:master Mar 28, 2017
warsaw deleted the issue19824 branch March 28, 2017 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants