I stumbled upon an interesting and unexpected feature of Python:
def fun():
"""Foo’s docstring"""
is a valid function? According to PEP 257, “A docstring is a string literal that occurs as the first statement in a module, function, class, or method definition” meaning that the docstring itself is considered a statement?
I would have expected that at least a pass
statement is required here. The above example contradicts the Python Zen of “explicit is better than implicit” as pass
states an explicit intent, and a docstring does not.
Can anybody shed some light on the intent?