On Thu, 13 Jan 2022 at 02:31, Steven Barker
While f-strings in class scope could theoretically be valid docstrings a lot of the time, the equivalent situation for function docstrings is much less positive. A function like this the one below obviously problematic, since the f-string value is not a compile-time constant:
def foo(x): f"is this a docstring? x is {x}"
I'm pretty sure f-strings cannot be used as docstrings in other contexts because of how broken they'd be in functions.
I don't have a horse in the race of whether this should be allowed or not for constant f-strings. I do however believe that having something like the example given previously where the code doesn't do what it appears to do, by silently not setting the docstring without giving a warning, is bad behaviour. -- Neil Muller drnlmuller@gmail.com