我想在多个类中重用用于同一函数的文档字符串。
例如
class square:
def getArea(L,W):
""" [description]
L (int) ...
W (int) ...
return (int) area of shape
"""
return L*W
class rectangle:
def getArea(L,W):
""" use docstring from above"""
return L*W
有没有办法在多个函数中使用相同的文档字符串?这是一个简单的例子,但有些函数有 10 个不同的参数,能够使用相同的文档字符串将确保一致性。