From: Mariatta Date: Fri, 10 Mar 2017 17:52:03 +0000 (-0800) Subject: bpo-28739: Document that f-strings cannot be used as docstring (GH-592) (GH-600) X-Git-Tag: v3.6.2rc1~335 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ff6f3716279e75b2519133a82b9de0c3601963d9;p=python bpo-28739: Document that f-strings cannot be used as docstring (GH-592) (GH-600) (cherry picked from commit d4e89287b397c7382c12d3f3d9fd901fd8243b3c) --- diff --git a/Doc/reference/lexical_analysis.rst b/Doc/reference/lexical_analysis.rst index da7017afff..7f9c664817 100644 --- a/Doc/reference/lexical_analysis.rst +++ b/Doc/reference/lexical_analysis.rst @@ -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.