在Python代码中写版权信息
在Python代码中,写“版权信息”的标准方式是什么呢?应该放在文档字符串里,还是放在块注释中?我在PEP文档里找不到相关的信息。
4 个回答
16
# Comment in the beginning of the file
至少Python自带的模块是这样做的。(我通过运行 grep 'Copyright' /usr/lib64/python2.4/*.py
发现的)
44
有些项目会使用像 __license__
这样的模块变量,比如:
__author__ = "Software Authors Name"
__copyright__ = "Copyright (C) 2004 Author Name"
__license__ = "Public Domain"
__version__ = "1.0"
我觉得这是一种很干净的解决方案(当然,前提是你不要把太多内容塞进这些变量里),不过目前只有 __version__
这个变量使用得比较广泛,因为它在 PEP 8 中提到过。