__author__ 的起源是什么?

2024-05-12

使用私有元数据变量的约定在哪里__author__一个模块内部从何而来?

This http://mail.python.org/pipermail/python-dev/2001-March/013328.htmlPython 邮件列表线程似乎暗示了 2001 年有关它的一些讨论,但听起来该约定已经很普遍了。

除此之外,我只能找到此 PEP 有关包元数据 http://www.python.org/dev/peps/pep-0345/,这似乎有影响力,但充其量是切线的。

我想尝试找到一些有关该主题的明确材料,以便我的文档工具可以成功解析这些元数据变量。


我的猜测是,这是从旧时代开始的,当时打包元数据还不常见。 在 PEP 8 中,鼓励使用 _version_ 顶级变量,用于保存正在使用的版本控制系统的修订 ID。这可以追溯到2001年5月1日。 PEP 396 正在取代模块 _version_ 属性。

For _author_ python 开发邮件列表中有一篇关于此事的帖子。这可以追溯到2001年3月1日。作者质疑 _ 的使用author_: “下一步是什么 ? _可爱的签收_ ?".

由于 PEP 中没有提及,所以不用担心_author_。无论如何,打包元数据是我们的朋友。

http://mail.python.org/pipermail/python-dev/2001-March/013328.html http://mail.python.org/pipermail/python-dev/2001-March/013328.html



Ping just checked in this:

> Log Message:
> Add __author__ and __credits__ variables.
> 
> 
> Index: tokenize.py
> ===================================================================
> RCS file: /cvsroot/python/python/dist/src/Lib/tokenize.py,v
> retrieving revision 1.19
> retrieving revision 1.20
> diff -C2 -r1.19 -r1.20
> *** tokenize.py   2001/03/01 04:27:19 1.19
> --- tokenize.py   2001/03/01 13:56:40 1.20
> ***************
> *** 10,14 ****
>   it produces COMMENT tokens for comments and gives type OP for all operators."""
>   
> ! __version__ = "Ka-Ping Yee, 26 October 1997; patched, GvR 3/30/98"
>   
>   import string, re
> --- 10,15 ----
>   it produces COMMENT tokens for comments and gives type OP for all operators."""
>   
> ! __author__ = 'Ka-Ping Yee '
> ! __credits__ = 'first version, 26 October 1997; patched, GvR 3/30/98'
>   
>   import string, re

I'm slightly uncomfortable with the __credits__ variable inserted
here.  First of all, __credits__ doesn't really describe the
information given.  Second, doesn't this info belong in the CVS
history?  I'm not for including random extracts of a module's history
in the source code -- this is more likely than not to become out of
date.  (E.g. from the CVS log it's not clear why my contribution
deserves a mention while Tim's doesn't -- it looks like Tim probably
spent a lot more time thinking about it than I did.)

Anothor source of discomfort is that there's absolutely no standard
for this kind of meta-data variables.  We've got __version__, and I
believe we once agreed on that (in 1994 or so :-).  But __author__?
__credits__?  What next -- __cute_signoff__?
  
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

__author__ 的起源是什么? 的相关文章

随机推荐