【问题标题】:How to specify return type and describe the return value in one-line ReST docstring?如何在一行 ReST 文档字符串中指定返回类型并描述返回值?
【发布时间】:2018-06-14 05:14:08
【问题描述】:

我知道我可以缩写以下 ReST 文档字符串

"""
:type flag: bool
:param flag: new value for the flag
"""

作为

"""
:param bool flag: new value for the flag
"""

我可以用类似的方式缩写吗?

"""
:rtype: bool
:returns: new value of flag
"""

【问题讨论】:

    标签: python restructuredtext docstring


    【解决方案1】:

    这是不可能的。必须在returnsreturn 中指定描述,并在rtype 中指定返回类型。不允许将它们合并为一行。

    【讨论】:

      猜你喜欢
      • 2021-07-17
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-24
      相关资源
      最近更新 更多