gpt4 book ai didi

python - Python 模块注释有约定吗?

转载 作者:太空狗 更新时间:2023-10-29 16:56:29 25 4
gpt4 key购买 nike

据我了解,模块文档字符串应该只提供模块功能的一般描述,而作者和版本等详细信息应该只包含在模块的注释中。

但是,我在评论文档字符串中看到了以下内容:

__author__ = "..."
__version__ = "..."
__date__ = "..."

放置这些元素的正确位置在哪里?还有哪些 __[name]__ 变量通常列在模块顶部?

最佳答案

它们只是约定,尽管是相当广泛使用的约定。参见 this description一组 Python 元数据要求。

__version__Python Style Guide 中提到.

关于文档字符串,有一个 PEP just for you !

The docstring for a module should generally list the classes, exceptions and functions (and any other objects) that are exported by the module, with a one-line summary of each. (These summaries generally give less detail than the summary line in the object's docstring.) The docstring for a package (i.e., the docstring of the package's init.py module) should also list the modules and subpackages exported by the package.

关于python - Python 模块注释有约定吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3635988/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com