【发布时间】:2014-11-03 10:45:20
【问题描述】:
为字典参数添加文档字符串的推荐方法是什么?我可以看到多行文档字符串示例here。
我需要在文档字符串中记录函数的输入参数。如果它是一个简单的变量,我可以使用类似的东西:
def func2(a=x, b = y):
""" fun2 takes two integers
Keyword arguments:
a -- refers to age (default 18)
b -- refers to experience (default 0)
"""
如果我们将dict 作为输入参数传递给函数:
def func3(**kwargs):
""" takes dictionary as input
<Here how to explain them - Is it like?>
kwargs['key1'] -- takes value1
<or simply>
key1 -- takes value1
"""
【问题讨论】:
-
你能解释一下你的意思吗?你的意思是如何记录一个应该是字典的参数?
-
是的,如何记录作为字典的参数。
标签: python dictionary docstring