在python代码中写入版权信息

发布于 2024-08-17 13:10:36 字数 65 浏览 4 评论 0原文

在Python代码中编写“版权信息”的标准方式是什么?它应该在文档字符串中还是在块注释中?我在 PEP 中找不到它。

What is the standard way of writing "copyright information" in python code? Should it be inside docstring or in block comments? I could not find it in PEPs.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

不乱于心 2024-08-24 13:10:36

有些项目使用诸如 __license__ 之类的模块变量,如下所示:

__author__ = "Software Authors Name"
__copyright__ = "Copyright (C) 2004 Author Name"
__license__ = "Public Domain"
__version__ = "1.0"

对我来说似乎是一个非常干净的解决方案(除非您过度使用并将史诗文本转储到这些变量中),但只有 __version__ 似乎被广泛使用,正如 PEP 8 中提到的那样。

Some projects use module variables like __license__, as in:

__author__ = "Software Authors Name"
__copyright__ = "Copyright (C) 2004 Author Name"
__license__ = "Public Domain"
__version__ = "1.0"

Seems like a pretty clean solution to me (unless you overdo it and dump epic texts into these variables), but only __version__ seems to be in widespread use, as it is mentioned in PEP 8.

锦爱 2024-08-24 13:10:36
# Comment in the beginning of the file

至少 python 内置模块可以做到这一点。 (通过执行 grep 'Copyright' /usr/lib64/python2.4/*.py 发现)

# Comment in the beginning of the file

At least python built-in modules do this. (found out by doing grep 'Copyright' /usr/lib64/python2.4/*.py)

春花秋月 2024-08-24 13:10:36

我们遵循软件自由法律中心网站上找到的建议(某处)。 这里是一个简单的 GPL 文件示例。

We follow the recommendations found (somewhere) on the Software Freedom Law Center's site. Here is an example of a simple GPL'ed file.

宣告ˉ结束 2024-08-24 13:10:36

据我所知,目前还没有标准的方法。每个公司/组织都会有自己的模板来记录版权信息。如果这是您的个人项目,那么请随意以您感觉最舒服的方式记录它。对于具有许多源文件的项目来说,添加 LICENSE 文件是一种非常常见的方法。即使在 Python 中,目前也没有关于文档字符串结构的标准。

Python 提供了很多自由,所以就让它成为吧伙计;)

As I know, there is currently no standard way. Each company/organization will have their own template to doc the copyright information. If this is your personal project, then just feel free to doc it in the way you feel most comforable. Adding a LICENSE file is a very common way for projects with many source files. Even in Python, there is currently no standard on the structure of docstrings.

Python provides a lot of freedom, so just let it be dude ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文