Skip to content

Commit

Permalink
bpo-28739: Document that f-strings cannot be used as docstring (pytho…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariatta committed Mar 10, 2017
1 parent 50da40f commit d4e8928
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Doc/reference/lexical_analysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit d4e8928

Please sign in to comment.