[docs] [issue25179] PEP 498 f-strings need to be documented

Martin Panter report at bugs.python.org
Sat Feb 6 22:06:43 EST 2016


Martin Panter added the comment:

Regarding doc strings, it seems that a constant f-string without any interpolations does become a doc string. But I would treat this as an implementation detail, not something to advertise.

Attached is my attempt at a patch. Please have a look and let me know if there are things I missed, if I added too much detail, wrong terminology, or whatever. I haven’t really written documentation like this before.

The combinations and permutations of all the Fr". . ." prefixes are getting borderline out of hand in the lexical_analysis.rst grammar. Any suggestions?

I put the bulk of the documentation in a new section “Formatted string literals” of the Lexical Analysis chapter, the same place that describes escape sequences and raw strings. Let me know if there is a more appropriate place for it. It doesn’t feel quite right where it is because this chapter comes before Expressions, and f-strings use expressions inside them.

I also made minimal changes to existing parts of the documentation and tutorial, to point to the new documentation. Perhaps some code examples could be changed from str.format() to f". . .", but I think that would be the subject of a separate patch. There are even places that still use the outdated "{0}".format() numbering.

----------
keywords: +patch
nosy: +martin.panter
stage: needs patch -> patch review
Added file: http://bugs.python.org/file41839/f-strings.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25179>
_______________________________________


More information about the docs mailing list