首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >返回类实例时的Numpydoc样式约定

返回类实例时的Numpydoc样式约定
EN

Stack Overflow用户
提问于 2019-12-09 14:52:06
回答 1查看 81关注 0票数 1

我遵循numpydoc 风格指南来记录我的代码,但找不到返回类实例的约定:

代码语言:javascript
复制
"""Create an index in the meilisearch API.  
If the argument \`uid\` isn't passed in, it will be generated by meilisearch.  
If the argument \`name\` isn't passed in, it will raise an error.  
Parameters  
----------  
name: str  
  Name of the index  
uid: str, optional  
  Unique identifier of the index  
Raises  
------  
HTTPError  
If no name is passed in as a parameter.  
HTTPError  
In case of any other error found here https://docs.meilisearch.com/references/#errors-status-code  
Returns  
-------  
index  
an instance of Index containing the information of the newly created index  
"""

在returns部分中,如您所见,我返回一个Index实例。这就是记录它的方法吗?

提前感谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-12-09 14:57:01

来自numpydoc风格指南

5.返回 解释返回的值及其类型。与参数部分类似,每个返回值的名称都是可选的。每个返回值的类型都是必需的。

代码语言:javascript
复制
Returns
-------
int
    Description of anonymous integer return value.

因此,对于您的示例,您将使用Index作为类型,以及一个可选的名称:

代码语言:javascript
复制
Returns
-------
index : Index
    <some meaningful description here>

在这里,index :部分是可选的。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59251348

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档