Skip to content

Commit d4e8928

Browse files
authored
bpo-28739: Document that f-strings cannot be used as docstring (pythonGH-592)
1 parent 50da40f commit d4e8928

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Doc/reference/lexical_analysis.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,17 @@ a temporary variable.
696696
>>> f"newline: {newline}"
697697
'newline: 10'
698698

699+
Formatted string literals cannot be used as docstrings, even if they do not
700+
include expressions.
701+
702+
::
703+
704+
>>> def foo():
705+
... f"Not a docstring"
706+
...
707+
>>> foo.__doc__ is None
708+
True
709+
699710
See also :pep:`498` for the proposal that added formatted string literals,
700711
and :meth:`str.format`, which uses a related format string mechanism.
701712

0 commit comments

Comments
 (0)