我更喜欢在声明参数的同一行记录每个参数(根据需要),以便应用DRY
如果我有这样的代码:
def foo(
flab_nickers, # a series of under garments to process
has_polka_dots=False,
needs_pressing=False # Whether the list of garments should all be pressed
):
...
如何避免重复文档字符串中的参数并保留参数说明?
我想避免:
def foo(
flab_nickers, # a series of under garments to process
has_polka_dots=False,
needs_pressing=False # Whether the list of garments should all be pressed
):
'''Foo does whatever.
* flab_nickers - a series of under garments to process
* needs_pressing - Whether the list of garments should all be pressed.
[Default False.]
这在带有某种装饰器操作的 python 2.6 或 python 3 中是否可行?还有其他方法吗?