]> granicus.if.org Git - python/commitdiff
bpo-28739: Document that f-strings cannot be used as docstring (GH-592)
authorMariatta <Mariatta@users.noreply.github.com>
Fri, 10 Mar 2017 16:58:40 +0000 (08:58 -0800)
committerGitHub <noreply@github.com>
Fri, 10 Mar 2017 16:58:40 +0000 (08:58 -0800)
Doc/reference/lexical_analysis.rst

index da7017afff0a3df54df7a7a188a6b30b7de03a22..7f9c66481785c1f6950bcd26c0acf58b56a81261 100644 (file)
@@ -696,6 +696,17 @@ a temporary variable.
    >>> f"newline: {newline}"
    'newline: 10'
 
+Formatted string literals cannot be used as docstrings, even if they do not
+include expressions.
+
+::
+
+   >>> def foo():
+   ...     f"Not a docstring"
+   ...
+   >>> foo.__doc__ is None
+   True
+
 See also :pep:`498` for the proposal that added formatted string literals,
 and :meth:`str.format`, which uses a related format string mechanism.