What is the origin of __author__?

我的梦境 提交于 2019-12-21 03:25:18

问题


Where does the convention of using private metadata variables like __author__ within a module come from?

This Python mailinglist thread seems to hint at some discussion about it in 2001, but by the sound of it the convention was already out in the wild.

Other than that, I can only find this PEP on package metadata, which seems influential but tangental at best.

I'd like to try and find some explicit material on the subject so my documentation tool can parse these metadata variables successfully.


回答1:


My guess is, it's from the old times when packaging meta data was not common then. In PEP 8 one is encouraged to use the __version__ top level variable to hold the revision id of the versioning system in use. This dates back to 2001-05-01. PEP 396 is superseding this for module __version__ attributes.

For __author__ there is a post from the python dev mailing list, concerning this matter. This one dates back to 2001-03-01. The author questions the use of __author__: "What's next ? __cute_signoff__ ?".

Since there is no mention in the PEPs, we don't have to worry about __author__. Packaging metadata is our friend anyway.

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__?


来源:https://stackoverflow.com/questions/9531136/what-is-the-origin-of-author

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!