为什么动态格式化文档字符串不起作用?在功能定义时有没有可接受的解决方法?
>>> DEFAULT_BAR = "moe's tavern"
>>> def foo(bar=DEFAULT_BAR):
... """
... hello this is the docstring
...
... Args:
... bar (str) the bar argument (default: {})
... """.format(DEFAULT_BAR)
...
>>> foo.__doc__
>>> foo.__doc__ is None
True
Run Code Online (Sandbox Code Playgroud)
我尝试使用old-skool样式的%s格式,但也无法正常工作.